CentOS 8安裝Mysql8並設置開機自啟動


1, 看起來mysql又提供yum安裝了。
yum install mysql-server
先安裝wget
yum -y install wget

2,下載rpm安裝文件
wget http://repo.mysql.com/mysql-community-release-el7.rpm

3,執行rpm安裝
rpm -ivh mysql-community-release-el7.rpm
依賴解析完成后,出現下列選項:

 1 Dependencies Resolved
 2 
 3 ================================================================================================================================================================
 4  Package                                                  Arch                 Version                  Repository                          Size
 5 ================================================================================================================================================================
 6 Installing:
 7  mysql-community-libs                                    x86_64              5.6.32-2.el7             mysql56-community                    2.0 M
 8  replacing  mariadb-libs.x86_64 1:5.5.47-1.el7_2
 9  mysql-community-server                                  x86_64              5.6.32-2.el7             mysql56-community                     59 M
 10  Installing for dependencies:
 11  mysql-community-client                                  x86_64              5.6.32-2.el7             mysql56-community                     19 M
 12  mysql-community-common                                  x86_64              5.6.32-2.el7             mysql56-community                    256 k
 13  perl-Compress-Raw-Bzip2                                 x86_64              2.061-3.el7              base                                  32 k
 14  perl-Compress-Raw-Zlib                                  x86_64              1:2.061-4.el7            base                                  57 k
 15  perl-DBI                                                x86_64              1.627-4.el7              base                                 802 k
 16  perl-IO-Compress                                        noarch              2.061-2.el7              base                                 260 k
 17  perl-Net-Daemon                                         noarch              0.48-5.el7               base                                  51 k
 18  perl-PlRPC                                              noarch              0.2020-14.el7            base                                  36 k
 19 
 20 Transaction Summary
 21 ================================================================================================================================================================
 22 Install  2 Packages (+8 Dependent packages)
 23 
 24 Total download size: 82 M
 25 Is this ok [y/d/N]: 

4,可以看出,server和client都被選擇安裝。選擇y,自動下載安裝。

5,安裝完成后,啟動Mysql。
systemctl start mysqld.service

啟動

1、使用 service 啟動:service mysqld start

2、使用 mysqld 腳本啟動:/etc/inint.d/mysqld start

停止

1、使用 service 啟動:service mysqld stop

2、使用 mysqld 腳本啟動:/etc/inint.d/mysqld stop

重啟

1、使用 service 啟動:service mysqld restart

2、使用 mysqld 腳本啟動:/etc/inint.d/mysqld restart

登錄mysql:mysql -u root -p(開始密碼默認為空,直接回車)

6,設置密碼
use mysql
ALTER USER 'root'@'localhost' IDENTIFIED BY '密碼';

/update user set password=password("123456") where user='root';/

7,開機自啟動
systemctl enable mysqld
systemctl daemon-reload

8,重要更新
新的rpm安裝文件沒有自動yum安裝的腳本了,需要手動執行yum安裝。

即步驟3之后執行yum install mysql-server即可。

9,關於自啟動

步驟7只適用於mysqld沒有自啟動的條件下。

如果默認mysql是自啟動的,可能和rc.local中的自啟動出現亂序之類的問題。

更穩妥的一個解決辦法見:

CentOS 7 程序自啟動的問題

http://www.cnblogs.com/yoyotl/p/6194321.html

打開遠程訪問:

修改host為所有ip可登陸
update user set host='%' where user='root';
修改密碼
Alter user 'root'@'%' identified by '密碼';
授權
grant all privileges on *.* to 'root'@'%' with grant option;
FLUSH PRIVILEGES;
詳解查看:https://www.cnblogs.com/stronger-xsw/p/12785801.html

1:linux登錄mysql

[root@localhost mysql]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 8.0.13 MySQL Community Server - GPL

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

2:查看user表,修改連接級別

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select host,user from user;
+-----------+------------------+
| host      | user             |
+-----------+------------------+
| localhost | root             |
| localhost | mysql.infoschema |
| localhost | mysql.session    |
| localhost | mysql.sys        |
+-----------+------------------+
4 rows in set (0.00 sec)

原文鏈接:https://blog.csdn.net/gdsgdh308227363/article/details/103308801


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM