mysql快速安装
2020-03-06 本文已影响0人
SYfarming
一、检查系统是否安装老版本,有的话干掉
#yum list installed | grep mysql
mysql-libs.x86_64 5.1.73-5.el6_6 @anaconda-CentOS-201508042137.x86_64/6.7
#yum -y remove mysql-libs.x86_64
二、安装及配置
# wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
# rpm -ivh mysql-community-release-el6-5.noarch.rpm
# yum repolist all | grep mysql
安装MYSQL数据库(网络原因,下载时间过长,这是唯一的缺点,如果机房网络环境好可以这样装)
# yum install mysql-community-server -y
设置为开机启动)
# chkconfig --list | grep mysqld
# chkconfig mysqld on
三、设置远程root
1.启动mysql和设置密码、登录
# service mysqld start
# mysql_secure_installation
# mysql -uroot -p
2.建立远程root用户
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '你设置的密码' WITH GRANT OPTION;
mysql> flush privileges;
四、设置utf-8编码
查看mysql原来编码:
mysql> show variables like 'character%';
设置编码
# vi /etc/my.cnf
如下(少补):
按 Ctrl+C 复制代码
修改
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
[mysql]
default-character-set = utf8
[mysql.server]
default-character-set = utf8
[mysqld_safe]
default-character-set = utf8
[client]
default-character-set = utf8
按 Ctrl+C 复制代码
重启mysql
# service mysqld restart
再次查看编码:
# mysql -uroot -p
mysql> show variables like 'character%';
完成yum方式安装。
总结:如果网络下载速度快,可以用这种方式