Centos6 install mysql

1. Check whether other versions of MYSQL data are installed in the system
#yum list installed | grep mysql
#yum -y remove mysql-libs.x86_64
2. 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
# yum install mysql-community-server -y
Set it to start at boot (2, 3, and 4 are all on, which means it starts automatically at boot)
# chkconfig --list | grep mysqld
# chkconfig mysqld on
3. Set up remote root
start mysql
# service mysqld start
set root password
# mysql_secure_installation
Log in to the root account
# mysql -uroot -p
Create a remote root user
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'The password you set' WITH GRANT OPTION;
mysql> flush privileges;

 

Fourth, set utf-8 encoding

View the original encoding of mysql:
mysql> show variables like 'character%';
set encoding
# vi /etc/my.cnf
As follows (less supplement):
copy code
[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci
sql_mode='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
copy code

restart mysql

# service mysqld restart

Check out the encoding again:

copy code
     # 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)
Reference https://www.cnblogs.com/007sx/p/7083143.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325485025&siteId=291194637