RedHat 6 Installing MySQL 5.5 process records and related problem solutions

Source: Internet
Author: User
Tags mysql client iptables

[TOC]

1. Install MySQL1.1 in RedHat using Yum mode to remove the system's own MySQL 5.1
rpm|grep mysql   #查看已经安装的mysqlrpm -e mysql            #普通删除模式rpm -e --nodeps mysql  #强力删除模式
1.2 Uninstall RPM package with Yum to prevent MySQL installation conflicts
yum -y remove mysql-libs-5.1.66*
1.3 Creating a local Yum repository configuration
vi /etc/yum.repos.d/local.repo

Add the following section:

[localrepo]name = myLocalYumRepobaseurl = /home/rhel/Downloads/MySQL-5.5.58-l.el6-rpmgpgcheck = 0enable = 1

baseurlit points to the path where my MySQL RPM package is located.

1.4 Yum Install MySQL

Once configured local_yum_repo , cd enter baseurl the directory where you can install the following three:

yum install MySQL-server-5.5.58-1.el6.x86_64.rpmyum install MySQL-client-5.5.58-1.el6.x86_64.rpmyum install MySQL-devel-5.5.58-1.el6.x86_64.rpm
1.4.1 Uninstalling MySQL

Use the command to see what MySQL programs have been installed:

rpm -qa|grep -i mysql

Use the RPM installation to uninstall using the following command:

rpm -ev MySQL-client-5.5.58-1.el6.x86_64 --nodepsrpm -ev MySQL-devel-5.5.58-1.el6.x86_64 --nodepsrpm -ev MySQL-server-5.5.58-1.el6.x86_64 --nodeps

To find the original MySQL directory:

find / -name mysql

Find the following to delete:

rm -rf /usr/lib64/mysqlrm -rf /var/lib/mysqlrm -rf /var/lib/mysql/data/mysqlrm -rf /var/lib/mysql/mysql

Manually delete/etc/my.cnf

Finally, check it out again. MySQL installed:

rpm -qa|grep -i mysql

If it is not displayed, it is already uninstalled.

1.5 Description of the directory after installation

After installation MySQL main default storage file directory:

/usr/bin                 #这里存放脚本和客户端程序/var/lib/mysql        #mysql的数据存储目录/usr/share/mysql  #mysql存放的初始化相关脚本
1.6 MySQL configuration file

Edit:vi /etc/my.cnf

# The MySQL Client[client]#客户端默认连接字集集,若编译安装时已指定则不用填写#character-set-server = utf8#客户端连接通信端口port = 3306#客户端通信的用户密码端口等信息保存文件socket = /var/lib/mysql/mysql.sockdefault-character-set=utf8# The MySQL server[mysqld]#mysql服务端监听端口port  = 3306     #mysql数据库存放目录datadir = /var/lib/mysql/datasocket = /var/lib/mysql/mysql.sock#服务端pid进程文件,若丢失则重启Mysql重新生成,若重启失败,#则可能由于mysqld进程未杀死,用pkill mysql后则能重启成功Mysql#pid-file =/opt/mysql/data/myDBserver.pidbind-address = 0.0.0.0[mysql]socket = /var/lib/mysql/mysql.sock
1.7 Initializing MySQL

Use the default path:

/usr/bin/mysql_install_db --user=mysql
1.8 Modify MySQL directory owner and user group to "MySQL"
chown -R mysql /var/lib/mysql/chgrp -R mysql /var/lib/mysql/
1.9 Starting and stopping MySQL

To start the MySQL service:

#/etc/init.d/mysqld start  # rhel 没有这个命令/etc/init.d/mysql start

To stop the MySQL service:

/etc/init.d/mysql stop
1.10 Modify the default password for the MySQL root user

(1) Mode 1:

    1. Use the command first: mysql go to MySQL

    2. Execute SQL statement to update root password

sql update mysql.user set password=PASSWORD(‘Cs123456‘) where user=‘root‘;

    1. Refresh the permissions, then you can.

sql flush privileges;

(2) Mode 2:

Another way to modify the root user password is to execute the shell command:

mysqladmin -u root password Cs123456
1.11 Log in to MySQL command format
mysql [-u username] [-h host] [-p[password]] [dbname]

For example:

mysql -u root -pCs123456 -h localhost
1.12 Remote connection Authorization for root
mysql -uroot -p'Cs123456'GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;FLUSH PRIVILEGES;

If you do not want to authorize a remote connection to root, we can create a new user specifically for use as a remote connection, such as "test":

createuseridentifiedby'Cs123456';grantallprivilegesonto'test'@'%'by'Cs123456'withgrantoption;flushprivileges;

@‘%‘It means to open all IP addresses.

To modify a user's password, use the following statement:

updateset password=password('新密码'where User="test"and Host="localhost";flushprivileges;

To delete a user:

deletefromuserwhere User='test'and Host='localhost';flushprivileges;
1.13 Troubleshooting MySQL's inability to connect remotely
vi /etc/my.cnf

Will bind-address = 127.0.0.1 , set tobind-address = 0.0.0.0

2. Problems encountered during installation ★error! MySQL server PID file could not being found!

Cause: The MySQL process is stuck dead.
Workaround:

1.杀死mysql进程:killall mysqld2.重启mysql:service mysql start
★error 2002 (HY000): Can ' t connect to local MySQL server through socket '/var/lib/mysql/tmp/mysql.sock '

Cause: mysql.sock The file may not be in the correct location

Workaround:

1, first find mysql.sock the location:

lsof -c mysqld|grep sock$

This path was found:/var/lib/mysql/mysql.sock

2 vi /etc/my.cnf . Configure and change the path of the socket to the [mysqld] [mysql] [client] path found above.

★starting MySQL. error! The server quit without updating PID file (/var/lib/mysql/data/mydbserver.pid

Possible causes: last MySQL abnormal shutdown

Workaround: Create a mydbserver.pid empty file and arbitrarily set a PID that is not in the process

vi /var/lib/mysql/data/myDBserver.pid23432

Then restart the MySQL service, if there is no other reason, it can start normally.

★ About remote access MySQL appears access denied for user ' root ' @ '

Two situations can cause this problem:

(1) root password input error

(2) There is no authorization to open the root external remote connection on the MySQL server. The solution can be consulted (1.)

★ Configure firewall, turn on port 3306

First look at the firewall open ports:

iptables -nL --line-number

Show drop on behalf of firewall blocked Port 3306.

Change the firewall and release port 3306:

vim /etc/sysconfig/iptables

On the COMMIT line, add the following:

-A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT

To restart the firewall:

service iptables restart

See if 3306 becomes ACCEPT , and if so, the port is already open.

RedHat 6 Installing MySQL 5.5 process records and related problem solutions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.