安装MySql
1、先需要查看系统当中有没有安装mariadb
mariadb和mysql同源
ps ajx |grep mariadb
2、把mariadb.service停掉
systemctl stop mariadb.service
3、检测是否被停掉
ps axj |grep mariadb
4、查看mariadb/mysql安装的rpm包
rpm -qa |grep mariadb
rpm -qa |grep mysql
5、卸载显示出来的mariadb/mysql安装包
sudo yum remove mariadb
备份/etc/my.cnf,备份/var/lib/mysql数据
6、安装
获取mysql官方yum源 :http://repo.mysql.com/
wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm
对比前后yum源
ls /etc/yum.repos.d/ -al
安装yum源
sudo rpm -Uvh mysql57-community-release-el7-10.noarch.rpm
对比前后yum源
ls /etc/yum.repos.d/ -al
查看能不能正常工作
yum list |grep mysql
安装mysql服务
sudo yum install -y mysql-community-server
如果显示安装失败需要加上 --nogpgcheck
sudo yum install -y mysql-community-server --nogpgcheck
查看配置文件
ls /etc/my.cnf
sudols /var/lib/mysql
启动服务
systemctl start mysqld.service
(停止服务:systemctl stop mysqld)
查看启动服务
ps axj |grep mysqld
sudols -al /var/lib/mysql
7、密码
获取临时root密码
sudogrep'temporary password' /var/log/mysqld.log
使用临时root 密码
mysql -uroot -p
判断修改密码时候新密码是否符合当前的策略,不满足报错,不让修改,Mysql的密码级别有三种,0级别,1级别,2级别 0级别允许是纯数字,1级别必须包含数字和字母,2级别必须数字,大小写字母都包含。
次操作密码设置为最低级别:
set global validate_password_policy=0;
设置密码最小长度
set global validate_password_length=1;
修改本地密码,暂不授权远端登录
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
FLUSH PRIVILEGES;
开启开机自启动
systemctl enable mysqld
systemctl daemon-reload
8、配置 /etc/my.cnf
主要是数据库客户端和服务器的编码格式
# For advice on how to change settings please see# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html[mysqld]## Remove leading # and set to the amount of RAM for the most important data# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.# innodb_buffer_pool_size = 128M## Remove leading # to turn on a very important data integrity option: logging# changes to the binary log between backups.# log_bin## Remove leading # to set options mainly useful for reporting servers.# The server defaults are faster for transactions and fast SELECTs.# Adjust sizes as needed, experiment to find the optimal values.# join_buffer_size = 128M# sort_buffer_size = 2M# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
port=3306
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
character-set-server=utf8
default-storage-engine=innodb
9、确保终端命令行中可以输入中文
mysql 已经配置了客户端服务器utf8编码,但是无法输入中文
env|grep LANG
版权归原作者 qnbk 所有, 如有侵权,请联系我们删除。