1.解压
tar -xvf mysql-5.7.21-1.el7.x86_64.rpm-bundle.tar
2.移除centos7自带的mariadb-libs包
yum remove -y mariadb-libs
3.安装解压后的rpm包
In most cases, you need to install the mysql-community-server
, mysql-community-client
, mysql-community-libs
, mysql-community-common
, and mysql-community-libs-compat
packages to get a functional, standard MySQL installation. To perform such a standard, basic installation, go to the folder that contains all those packages
yum install mysql-community-{server,client,common,libs}-*
A standard installation of MySQL using the RPM packages result in files and resources created under the system directories, shown in the following table.
Files or Resources | Location |
---|---|
Client programs and scripts | /usr/bin |
mysqld server | /usr/sbin |
Configuration file | /etc/my.cnf |
Data directory | /var/lib/mysql |
Error log file | For RHEL, Oracle Linux, CentOS or Fedora platforms: For SLES: |
Value of secure_file_priv |
/var/lib/mysql-files |
System V init script | For RHEL, Oracle Linux, CentOS or Fedora platforms: For SLES: |
Systemd service | For RHEL, Oracle Linux, CentOS or Fedora platforms: For SLES: |
Pid file | /var/run/mysql/mysqld.pid |
Socket | /var/lib/mysql/mysql.sock |
Keyring directory | /var/lib/mysql-keyring |
Unix manual pages | /usr/share/man |
Include (header) files | /usr/include/mysql |
Libraries | /usr/lib/mysql |
Miscellaneous support files (for example, error messages, and character set files) | /usr/share/mysql |
4.启动并登陆MySQL
systemctl start mysqld.service
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.
-
An 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 for RHEL, Oracle Linux, CentOS, and Fedora systems:
找出root的密码
grep 'temporary password' /var/log/mysqld.log
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
设置允许远程访问
grant all privileges on *.* to 'root'@'%' identified by 'password' with grant option;