Install MySql Server 5.7(或8.0)

2018-10-21  本文已影响0人  逍遥无铭

详细安装步骤参见官方文档:
https://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html

1. 先下载MySQL Yum Repository
wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm

2.Install the downloaded release package
sudo yum localinstall mysql80-community-release-el7-1.noarch.rpm;

3. 编辑mysql-community.repo, 将enable 5.7, disable 8.0

8.0默认是enabled,其它版本默认是disabled.(enabled=0为disabled,1为enabled,其它的不要修改)
vim /etc/yum.repos.d/mysql-community.repo

# Enable to use MySQL 5.7

[mysql57-community]

name=MySQL 5.7 Community Server

baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql80-community]

name=MySQL 8.0 Community Server

baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch/

enabled=0

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

4. 查看当前enbled的版本是否正确:

yum repolist enabled | grep mysql

5. 安装MySql-Server

shell> sudo yum install mysql-community-server

6. Start the MySql-Server

Start the MySQL server with the following command:

shell> sudo service mysqld start 

Starting mysqld:[OK]

You can check the status of the MySQL server with the following command:

shell> sudo service mysqld status

mysqld(pid 3066)is running.

At the initial start up of the server, the following happens, given that the data directory of the server is empty:

The server is initialized.

SSL certificate and key files are generated in the data directory.

validate_password is installed and enabled.

A superuser account 'root'@'localhost is created. A password for the superuser is set and stored in the error log file. To reveal it, use the following command:

shell> sudo grep 'temporary password' /var/log/mysqld.log

Change the root password as soon as possible by logging in with the generated, temporary password and set a custom password for the superuser account:

shell> mysql -uroot -p

mysql>ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';

Note

validate_password is installed by default. The default password policy implemented by validate_passwordrequires that passwords contain at least one upper case letter, one lower case letter, one digit, and one special character, and that the total password length is at least 8 characters.

上一篇下一篇

猜你喜欢

热点阅读