The installation environment is as follows:
Centos 7.464 people
Mysql 5.7
After ssh connects to the target server, use wget to download version 5.7 of MySQL Yum
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
Then install MySQL Yum with yum
yum localinstall mysql57-community-release-el7-8.noarch.rpm
Then use the command to check whether MySQL Yum is installed successfully
yum repolist enabled | grep "mysql.*-community.*"
After the installation is successful, you will see the following prompt.
image
yum install mysql-community-server
systemctl start mysqld
//And so on
systemctl stop mysqld
systemctl restart mysqld
//The second, easy to remember
service msyqld start
service msyqld stop
service msyqld restart
systemctl enable mysqld
systemctl daemon-reload
Because after installation, the default password will be automatically generated for root, we use the following command to view the password, 5ejRwZBgquL is the default password.
[ root@VM_65_249_centos ~]# grep 'temporary password'/var/log/mysqld.log
2018- 06- 13 T04:04:42.144765Z 1[Note] A temporary password is generated for root@localhost: #5ejRwZBgquL
mysql -u root -p
Because mysql has a password security check plugin, your password must contain uppercase and lowercase English, numbers, characters and no less than 8 digits. Note that it ends with an English semicolon. Otherwise, the following error will be reported.
set password for'root'@'localhost'=password('YourNewPassword123!');
ERROR 1819(HY000): Your password does not satisfy the current policy requirements //Does not pass the password security plug-in check
Because the root user prohibits remote connections by default, you can change the policy to allow root to connect remotely, or create new users to connect remotely. For safety, create a new user ppjun
GRANT ALL PRIVILEGES ON *.* TO 'ppjun'@'%' IDENTIFIED BY 'YourNewPassword123!' WITH GRAN;
The meaning here is to let the user ppjun assign permissions to all tables in all databases of the machine, and set the password YourNewPassword123!
vi /etc/my.cnf
Add under [mysqld]
[ mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
Then in mysql, the encoding is utf8
mysql> show variables like '%character%';+--------------------------+----------------------------+| Variable_name | Value |+--------------------------+----------------------------+| character_set_client | utf8 || character_set_connection | utf8 || character_set_database | utf8 || character_set_filesystem | binary || character_set_results | utf8 || character_set_server | utf8 || character_set_system | utf8 || character_sets_dir |/usr/share/mysql/charsets/|+--------------------------+----------------------------+8 rows inset(0.00 sec)
the above.
Recommended Posts