Linux下卸载安装mysql

1、卸载命令:# rpm -qa |grep -i mysql 

  # yum remove mysql-community mysql-community-server mysql-community-libs mysql-community-common

2、安装:# wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

  # yum localinstall mysql57-community-release-el7-8.noarch.rpm

  # yum install mysql-community-server

3、启动 :# systemctl start mysqld

  重启:# systemctl restart mysqld

  关闭:# systemctl stop mysqld

  设置开机自启 # systemctl enable mysqld

         # systemctl daemon-reload

4、查看默认密码:# grep 'temporary password' /var/log/mysqld.log

  注:可修改密码策略(不然密码需要包括大小写、数字、特殊符号)

  # vim  /etc/my.cnf

  添加:validate_password = off

  # systemctl restart mysqld

5、登录:#  mysql -uroot -p

  修改密码:mysql> set password for 'root'@'localhost'=password('123123'); 

  添加远程账号:mysql> GRANT ALL PRIVILEGES ON *.* TO 'home'@'%' IDENTIFIED BY '123123' WITH GRANT OPTION;

7、配置默认编码utf-8:# vim /etc/my.cnf

  添加:   character_set_server=utf8

      init_connect='SET NAMES utf8'

8、默认配置文件路径: 

  配置文件:/etc/my.cnf 

  日志文件:/var/log//var/log/mysqld.log 

  服务启动脚本:/usr/lib/systemd/system/mysqld.service 

  socket文件:/var/run/mysqld/mysqld.pid

猜你喜欢

转载自www.cnblogs.com/wu-wu/p/10146826.html