How to install mysql under centos: 1. Download and install the official MySQL Yum Repository; 2. Install the MySQL server; 3. Log in to the database; 4. Modify the MySQL default password; 5. Enable remote access to mysql. Can.
The operating environment of this article: Windows 7 system, Mysql version 5.7.14, Dell G3 computer.
How to install mysql under centos?
CentOS7 installation MySQL (full version)
MariaDB is installed by default in CentOS. This is a branch of MySQL, but for needs, it still needs to be installed in the system. Install MySQL in and overwrite MariaDB directly after the installation is complete.
[root@localhost ~]# yum -y install mysql57-community-release-el7-10.noarch.rpm## Use the above command to directly download the Yum Repository for installation. , about 25KB, and then you can install it directly with yum.
[root@localhost ~]# yum -y install mysql57-community-release-el7-10.noarch.rpmThen start installing the MySQL server
[root@localhost ~]# yum -y install mysql-community-serverThis step may take some time. After the installation is completed, the previous mariadb will be overwritten. How long will it take? Depends on personal internet speed. After the installation is complete, let’s do some configuration of mysql. 2 MySQL database settings (1) First start MySQL
[root@localhost ~]# systemctl start mysqld.service(2) Check the running status of MySQL. The running status is as shown in the figure:
[root@localhost ~]# systemctl status mysqld.service(3) MySQL has started to run normally at this time, but in order to enter MySQL, you must first find out the password of the root user at this time. You can find the password in the log file through the following command:
[root@localhost ~]# grep "password" /var/log/mysqld.log(4) Log in to the database with the following command:
[root@localhost ~]# mysql -uroot -p(5) You cannot do anything at this time, because MySQL must change the password by default before you can operate the database. Use the following command to change the password:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';Replace 'new password' with the password you want to set. Note: The password setting must contain uppercase and lowercase letters and numbers and special symbols (,/';:, etc.), otherwise it cannot be configured. success. If the following error occurs: It is thought that the password complexity does not meet the default requirements. Use the following command to view the mysql default password complexity:
SHOW VARIABLES LIKE 'validate_password%';If you need to change the password complexity, please refer to the following command:
set global validate_password_policy=LOW;
set global validate_password_length=6;
##3 Open Mysql remote access
Execute the following command to enable remote access restrictions (note: the IP enabled by the following command is 192.168.19.128. If you want to enable all, use % instead of IP):
grant all privileges on *.* to 'root'@'192.168.0.1' identified by 'password' with grant option;
Note: password--is the password you set for your mysql remote login.
Then enter the following two lines of commands
mysql> flush privileges;You can also exit mysql for this step. Specific reference:
https://i-beta.cnblogs.com/posts?cateId=1653053
首先重新登录mysql,然后输入status:
可以看到,红色方框处不是utf-8,修改为utf8即可。
因此我们先退出mysql,然后再到/etc目录下的my.cnf文件下修改一下文件内容
cd /etc
进入文件后,新增四行代码:
保存更改后的my.cnf文件后,重启下mysql,然后输入status再次查看,你就会发现变化啦
到此CentOS7安装Mysql5.7完毕。
set global validate_password_policy=LOW;
【相关推荐:mysql视频教程】
The above is the detailed content of How to install mysql under centos. For more information, please follow other related articles on the PHP Chinese website!