Mysql installation configuration at centOS7

1, in the default CentOS installed MariaDB, MySQL is the branch, first delete

rpm -qa | grep mariadb 

会得到已经安装的mariadb列表
例如有一个:mariadb-libs-5.5.60-1.el7_5.x86_64
rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64

删除mariadb

2, the installation source yum

wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
sudo yum install mysql80-community-release-el7-1.noarch.rpm

3, to see if the installation was successful

sudo yum repolist all|grep mysql

Here Insert Picture Description
3, configure mysql version to install

sudo vim /etc/yum.repos.d/mysql-community.repo

enabled 为1表示启用,将要安装的版本的enabled改为1后保存


4, install mysql
this step a little longer. . . .

sudo yum install mysql-community-server.x86_64

5, start and view status

sudo service mysqld start      //启动mysql
sudo service mysqld status   //查看mysql状态
sudo systemctl enable mysqld //配置开机启动

Here Insert Picture DescriptionThat this has proved successful start

6, change passwords

  • Give root to generate a default password
  • grep 'temporary password' /var/log/mysqld.log
  • Enter mysql, and use generated passwords
  • mysql -uroot -p
  • change Password
  • ALTER USER 'root'@'localhost' IDENTIFIED BY '这里输入新密码';

mysql password requirements are very strict, by modifying the configuration can use a simple password

  • First check your parameter name
  • SHOW VARIABLES LIKE 'validate_password%';
  • Here Insert Picture Description`Modify validate_password.policy
  • set global validate_password.policy=0;
  • Modify password length
  • set global validate_password.length=你要的长度
  • Modify the new password, simple passwords such as 1234
  • ALTER USER 'root'@'localhost' IDENTIFIED BY '这里输入新密码';

7, view and modify encoded as utf8

  • Check coding case
  • show variables like '%char%';
  • Change profile
  • vim /etc/my.cnf
  • In the [client] Add next
    Note: If you do not [client] then add their own, but can not add [mysqld] Here
    I add to the [mysqld] above it
default-character-set=utf8
  • In [mysqld] Add the following
character_set_server=utf8
collation-server=utf8_general_ci
Released three original articles · won praise 3 · views 47

Guess you like

Origin blog.csdn.net/weixin_43848532/article/details/105016175