yum installed mysql (complete records)

2016-04-07 study notes, source code is more cumbersome to install, or to try to install yum and rpm installed

First, check whether the system is to install an older version, get rid of any
#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

Second, the installation and configuration
# 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
Install MYSQL Database (network reasons, the download time is too long, this is the only drawback, if room can be so good network environment installed)
# yum install mysql-community-server -y
Is set to boot)
# chkconfig --list | grep mysqld
# chkconfig mysqld on

Third, set up remote root
1. Start mysql and password, login
# service mysqld start
# mysql_secure_installation
# mysql -uroot -p 
2. Set up remote root user
. mysql> GRANT ALL PRIVILEGES ON * * TO 'root' @ '%' IDENTIFIED BY ' password you set' the WITH GRANT OPTION; 
MySQL> flush privileges;

 

Fourth, set utf-8 encoding 

to view the original mysql code:
mysql> show variables like 'character%';
Setting coding
# We /etc/my.cnf
Follows (less s):
# Change
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
 

Restart mysql

# service mysqld restart

View encoded again:

# mysql -uroot -p
mysql> show variables like 'character%';

Yum way to complete the installation.

Summary: If the network download speed, can be used in this way

 

First, check whether the system is installed other versions of MYSQL data
#yum list installed | grep mysql
#yum -y remove mysql-libs.x86_64

Second, the installation and configuration
# 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
设置为开机启动(2、3、4都是on代表开机自动启动)
# chkconfig --list | grep mysqld
# chkconfig mysqld on

三、设置远程root
启动mysql
# service mysqld start
设置root密码
# mysql_secure_installation
登陆root账号
# mysql -uroot -p 
建立远程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
如下(少补):
复制代码
[mysqld]
character-set-server=utf8 
collation-server=utf8_general_ci 
performance_schema_max_table_instances=400 
table_definition_cache=400 
table_open_cache=256
# 修改
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
复制代码

 

重启mysql

# service mysqld restart

再次查看编码:

复制代码
     # mysql -uroot -p
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 in set (0.00 sec)

Guess you like

Origin www.cnblogs.com/micfox/p/10989915.html