Centos6 install mysql using yum
Check whether MySQL is installed. --> run the following command:
Rpm-qa | grep mysql
Uninstall installed MySQL --> run the following command:
# Rpm-e -- nodeps mysql-libs -*
Delete all files in the/var/lib/mysql folder.
MySQL installation:
Run the following command to install mysql-server:
Yum-y install mysql-server
Run the initialization command after installation.
Service mysqld start or/etc/init. d/mysqld start
Modify the mysql configuration file (modify the default encoding)
Copy the my-large.cnf file to/etc/my. cnf --> execute the command:
Cp/usr/share/doc/mysql-server-4.1.12/my-large.cnf/etc/my. cnf
If you are prompted whether to overwrite, Y is enough;
Open my. cnf and modify the encoding --> run the following command:
Vi/etc/my. cnf
Add the following under [mysqld:
Default-character-set = utf8
Modify the specified default engine:
Default-storage-engine = INNODB
Case Sensitive: (0: Case Sensitive 1: Case Insensitive)
Lower_case_table_names = 1
Add the following under [client:
Default-character-set = utf8
4. Restart the MySQL service --> run the following command:
Service mysqld restart or/etc/init. d/mysqld restart
5. log on to mysql and run the following command:
Mysql or mysql-uroot-p
View mysql Encoding
Show variables like 'character % ';
Display:
+ -------------------------- + ---------------------------- +
| 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/|
+ -------------------------- + ---------------------------- +
Modified successfully;
Assign permissions to the host that connects to MySQL (facilitating remote connection to MySQL database ):
Mysql> grant all on *. * TO 'username' @ '%' identified by 'Password' with grant option;
// Please note that this is an SQL statement, not a linux Command. If you are not clear about this SQL statement, You can Google it.
Note: enable port 3306 on the firewall;
Vi/etc/sysconfig/iptables
-A input-p tcp-m state -- state NEW-m tcp -- dport 3306-j ACCEPT
Save and restart the service
/Sbin/service iptables restart
After the installation is complete, set the root password for MySQL --> use the command:
/Usr/bin/mysqladmin-u root password '123'
Modify the mysql root Password:
Set password for 'root' @ 'localhost' = PASSWORD ('newpass ');
Mysql installation directory
/Var/lib/mysql database file
/Usr/share/mysql command and configuration file
/Usr/bin (commands such as mysqladmin and mysqldump)