Install mysql5.1.73 and mysql5.1.73 on CentOS6.5
Ideas:
1. Check whether mysql has been installed.
rpm -qa|grep mysql
Or
yum list installed mysql
2. Check whether the installation package exists.
yum list mysql*
3. Install mysql Server
yum install mysql-serveryum install mysql-devel
4. Start & stop
A. Set the default database characters
Add default-character-set = utf8 to the mysql configuration file/etc/my. cnf.
vim /etc/my.cnf
B. Set auto-start upon startup
chkconfig mysqld onchkconfig --list mysqld
C. Start mysql
service mysqld start
5. log on
A. Create a root administrator.
mysqladmin -u root password 123456
B. Forget the password.
service mysqld stopmysqld_safe --user=root --skip-grant-tablesmysql -u rootuse mysqlupdate user set password=password("new_pass") where user="root";flush privileges;
6. Remote Access
A. Modify localhost
Change the "host" entry in the "user" table in the "mysql" database to "%" from "localhost"
mysql>use mysql; mysql>update user set host = '%' where user = 'root'; mysql>select host, user from user;mysql>FLUSH PRIVILEGES;
B. Specify authorization
1. Use myuser/mypassword to connect to the mysql server from any host:
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
2. Use myuser/mypassword to connect to the mysql server from the host with the ip address 192.168.225.166:
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.166' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
3. wildcard authorization
Mysql-h localhost-u root mysql> grant all privileges on *. * TO 'root' @ '%' with grant option; // GRANT any host the permission TO access data as root mysql> flush privileges;
7. Several important MySQL Directories
A. Database directory
/var/lib/mysql/
B. Configuration File
/Usr/share/mysql (mysql. server command and configuration file)
C. Related commands
/Usr/bin (commands such as mysqladmin mysqldump)
D. Start the script
/Etc/rc. d/init. d/(directory for starting the script file mysql)
8. uninstall mysql
A. Check whether mysql is installed before.
rpm -qa|grep -i mysql
B. Delete mysql
1、yum remove mysql mysql-server mysql-libs compat-mysql512、rm -rf /var/lib/mysql3、rm /etc/my.cnf
9. bug handling
A. ERROR 1045 (28000): Access denied for user 'root' @ 'localhost' (using password: YES)
Solution:
1. Stop the mysql server
service mysqld stop
2. Run the mysqld_safe command to start mysql and update the password of the root account.
mysqld_safe --user=mysql --skip-grant-tables --skip-networking &:
Note: -- skip-grant-tables: Do not start grant-tables (authorization table) and skip permission control.
-- Skip-networking: skip the TCP/IP protocol and only access it from the Local Machine (this option is not required according to some information on the Internet. No)
After executing the preceding command, the session window will be unresponsive. You need to use CTRL + C to interrupt the session.
3. Set the password
mysql -u root mysqlmysql> update user set password=PASSWORD('12345') -> where user='root' and host='root' or host='localhost';flush privileges
4. Start the mysql Service
service mysqld start