Details on installing Mysql and configuring mysql under CentOS7
- 2020-05-15 03:27:16
- OfStack
Finally, MySQL was installed under centos, using yum online installation. No source installation, because the online installation of time and effort.
In the last machine, I do not know why the online installation speed of yum was slow, so I could not download it, so I redid the system installation. As for the reason why the network speed was slow, I have not solved it for the time being.
Record 1 for the installation of MySQL:
First, since there is no MySQL source in yum, you need to install it using wget:
Download the repo source for mysql
$ wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
Install mysql-community-release-el7-5.noarch.rpm package:
$ sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
Install MySQL
$ sudo yum install mysql-server
This can be a bit long, wait patiently, if the network is not good or yum problems will fail to install, can only use the local source installation
Once installed, don't rush to log in.
cengtos after installation is complete will be randomly generated for root user a password, we can in grep "password"/var log/mysqld. log to check in.
Some tutorials say you need to use this random password to log in MySQL and then change the password.
Bullshit, what if the password contains special characters, like; And just quit.
The correct approach is to first modify the mysql file so that it can log in without a password:
$ vim /etc/my.cnf
Add under MySQL:
skip-grant-tables
Start the MySQL:
$ systemctl start mysqld
Enter mysql and you can log in without a username or password.
Next, change the password:
mysql> use MySQL;
mysql> update user set password=PASSWORD('root')where user='root';
In this case, it would be wrong:
ERROR 1054 (42S22): Unknown column 'password' in' in' list' field 'list', password field changed to authentication_string
Should use:
MySQL>update MySQL.userset authentication_string=password('root') where user='root' ;
MySQL>flush privileges;
Thus, the mysql configuration is successful
Start the MySQL
$ systemctl start mysqld
Login successful!
Finally, don't forget to delete the skip-grant-tables in /etc/ my.cnf
Restart mysql:
[root@bogon ~]# service mysqld restart