Linux under Yum install MySQL and uninstall

Source: Internet
Author: User

1. Check if you have installed:

Yum List installed mysql*

Rpm-qa | grep mysql*

2. Check that there are no installation packages:

Yum List mysql*

3. Install the MySQL client:

Yum install MySQL

4. Install the MySQL server side:

Yum Install Mysql-server

Yum Install Mysql-devel

5. Start && Stop

Database Character Set settings

MySQL config file/etc/my.cnf add Default-character-set=utf8

To start the MySQL service:

Service mysqld start or/etc/init.d/mysqld start

Boot start:

Chkconfig-add mysqld, check if boot boot settings are successful chkconfig--list | grep mysql*

Mysqld 0: Off 1: Off 2: Enable 3: Enable 4: Enable 5: Enable 6: Off

Stop it:

Service Mysqld Stop
If it does not start, check if the MYSQLD service is already open in the service

6. Login

To create a root administrator:

Mysqladmin-u Root Password 123456

Www.2cto.com

Login:

Mysql-u Root-p Enter the password.

Forgot Password:

Service Mysqld Stop

Mysqld_safe--user=root--skip-grant-tables

Mysql-u Root

Use MySQL

Update user set Password=password ("New_pass") where user= "root";

Flush privileges;

7. Remote Access

1. Modify localhost
Change the "host" entry in the "User" table in the "MySQL" database, changing from "localhost" to "%"
Mysql>use MySQL;
Mysql>update User Set host = '% ' where user = ' root ';
Mysql>select host, user from user;
Mysql>flush privileges;

2. Designated authorization
Connect to the MySQL server from any host using Myuser/mypassword:
GRANT all privileges on * * to ' myuser ' @ ' percent ' identified by ' MyPassword ' with GRANT OPTION;

Use Myuser/mypassword to connect to the MySQL server from a host with IP 192.168.225.166:
GRANT all privileges on * * to ' myuser ' @ ' 192.168.225.166 ' identified by ' MyPassword ' with GRANT OPTION;

3. Pan-Authorized
Mysql-h Localhost-u Root
Mysql>Grant all privileges on * * to ' root ' @ '% ' with GRANT OPTION; //give any host access to the data as root
Mysql>FLUSH privileges;

troubleshoot problems with MySQL not being able to connect remotely

1, MySQL port is correct
View port occupancy through NETSTAT-NTLP , typically 3306 for the lower end. The use of the tool to connect to MySQL is to use the port. For example, My admin\my Query browser\mysql front and so on.

2. Check whether the user rights are correct
The user table of the MySQL library has two records: host is localhost and% (for security,% can be replaced with IP you need to connect externally).

3. See if the skip-networking has been/etc/mysql/my.cnf
Need to be dropped
Error: Error 2003 (HY000): Can ' t connect to MySQL server on ' 192.168.51.112 ' (111)

sudo gedit/etc/mysql/my.cnf
#skip-external-locking

#bind-address = 127.0.0.1

Skip-name-resolve


4, check whether the iptables is stopped, does not close the case, can not connect
By: Service Iptables stop is temporarily closed.
Error: Error 2003 (HY000): Can ' t connect to MySQL server on ' 192.168.51.112 ' (113)

8. Linux several important directories for MySQL

Www.2cto.com

Database directory

/var/lib/mysql/

Configuration file

/usr/share/mysql (mysql.server command and configuration file)

Related commands

/usr/bin (Mysqladmin mysqldump and other commands)

Startup scripts

/etc/rc.d/init.d/(startup script file for MySQL directory)


Uninstall MySQL
1. Find out if MySQL was previously installed
Command: Rpm-qa|grep-i MySQL
You can see two of the MySQL packages:
mysql-*. *. rhel**
mysqlclient*. rhel**
2. Delete MySQL
Delete command: RPM-E--nodeps package Name
(Rpm-ev mysql-*. rhel*)
3, delete the old version of MySQL development header files and libraries
Command: Rm-fr/usr/lib/mysql
Rm-fr/usr/include/mysql
Note: The data and/etc/my.cnf in/var/lib/mysql after uninstallation are not deleted, if determined, then manually deleted
Rm-f/etc/my.cnf
Rm-fr/var/lib/mysql

There's another way.

Yum-style installation of MySQL

1. Yum remove MySQL mysql-server mysql-libs compat-mysql51

2, Rm-rf/var/lib/mysql

3, RM/ETC/MY.CNF

See if you have MySQL software:
Rpm-qa|grep MySQL

If it exists, continue with the deletion.

RPM-style installation of MySQL

A) Check to see if MySQL is installed in the RPM package on the system:

[Email protected] opt]# Rpm-qa | Grep-i MySQL
mysql-server-5.6.17-1.el6.i686
mysql-client-5.6.17-1.el6.i686

b) Uninstall MySQL

[Email protected] local]# rpm-e mysql-server-5.6.17-1.el6.i686
[Email protected] local]# rpm-e mysql-client-5.6.17-1.el6.i686

c) Delete MySQL service

[Email protected] local]# Chkconfig--list | Grep-i MySQL
[[email protected] local]# chkconfig--del MySQL

d) Delete the distributed MySQL folder

[[email protected] local]# Whereis MySQL or find/-name MySQL

MySQL:/usr/lib/mysql/usr/share/mysql

Empty all directories and files related to MySQL
Rm-rf/usr/lib/mysql
Rm-rf/usr/share/mysql

Rm-rf/usr/my.cnf

With these steps, MySQL should have been completely uninstalled.

The entire process of uninstalling and installing MySQL under Linux

Uninstall MySQL

1. Find out if MySQL was previously installed

Command: Rpm-qa|grep-i MySQL

You can see two of the MySQL packages:

mysql-4.1.12-3.rhel4.1

mysqlclient10-3.23.58-4.rhel4.1

2. Delete MySQL

Delete command: RPM-E--nodeps package Name

(Rpm-ev mysql-4.1.12-3.rhel4.1)

3, delete the old version of MySQL development header files and libraries

Command: Rm-fr/usr/lib/mysql

Rm-fr/usr/include/mysql

Note: The data and/etc/my.cnf in/var/lib/mysql after uninstallation are not deleted, if determined, then manually deleted

Rm-f/etc/my.cnf

Rm-fr/var/lib/mysql

Install MySQL

Pre-installation: two RPM packages

mysql-client-5.1.20-0.glibc23.i386.rpm

mysql-server-5.1.20-0.glibc23.i386.rpm

1, install the service side:

Command: RPM-IVH mysql-server-5.1.20-0.glibc23.i386.rpm

Installation success will appear ....

Warning:mysql-server-5.1.20-0.glibc23.i386.rpm:v3 DSA Signature:nokey, key ID 5072e1f5

Preparing ... ########################################### [100%]

1:mysql-server ########################################### [100%]

080220 13:58:27 [Note] Plugin ' InnoDB ' disabled by command line option

080220 13:58:28 [Note] Plugin ' InnoDB ' disabled by command line option

REMEMBER to SET A PASSWORD for the MySQL root USER!

To does so, start the server, then issue the following commands:

/usr/bin/mysqladmin-u root password ' new-password '

/usr/bin/mysqladmin-u root-h localhost.localdomain password ' new-password '

See the Manual for more instructions.

Problems with The/usr/bin/mysqlbug script!

The latest information about MySQL was available on the Web at

Http://www.mysql.com

Support for MySQL by buying support/licenses at http://shop.mysql.com

Starting MySQL. [OK]

2. Install the Client

Command: RPM-IVH mysql-client-5.1.20-0.glibc23.i386.rpm

Successful performance:

[Email protected] ~]# RPM-IVH mysql-client-5.1.20-0.glibc23.i386.rpm

Warning:mysql-client-5.1.20-0.glibc23.i386.rpm:v3 DSA Signature:nokey, key ID 5072e1f5

Preparing ... ########################################### [100%]

1:mysql-client ########################################### [100%]

3. Log in to MySQL

The command to log in to MySQL is mysql,mysql using the following syntax:

MySQL [-u username] [-h host] [-p[password]] [dbname]

Username and password are mysql user name and password, MySQL's initial management account is root, no password, note: This root user is not a Linux system user. MySQL Default user is root, because the initial no password, the first time to enter the only need to type MySQL

[[email protected] ~]# MySQL

Welcome to the MySQL Monitor. Commands End With; or \g.

Your MySQL Connection ID is 2

Server Version:5.1.20-beta MySQL Community Server (GPL)

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the buffer.

Mysql>

There is a "mysql>" prompt, congratulations, installation success!

The login format after adding the password is as follows:

Mysql-u root-p

Enter Password: (enter password)

Where-u followed by the user name,-p requires a password, enter the password at the input password.

Note: This MySQL file is in the/usr/bin directory, and the boot file/etc/init.d/mysql is not a file.

Tween

Detailed procedures for installing, configuring, and uninstalling MySQL via RPM packages.

Take mysql-server-4.0.14-0.i386.rpm as an example and put it in the/data directory

Cd/data

RPM-IVH mysql-server-4.0.14-0.i386.rpm

After the installation is complete, there will be a MySQL startup script in the/usr/share/mysql directory Mysql.server and sample configuration files (such as MY-HUGE.CNF, MY-LARGE.CNF, MY-MEDIUM.CNF)

Copy a sample configuration file as a configuration file for MySQL:

Cp/usr/share/mysql/my-medium.cnf/etc/my.cnf

When the RPM package is installed, MySQL is automatically installed as a system service, so you can start and stop MySQL using the following command

Start MySQL

/etc/init.d/mysql start or service MySQL start

Stop MySQL

/etc/init.d/mysql stop or service MySQL stop

To this, the MySQL service is complete on the installation configuration.

Installing the MySQL Client

RPM-IVH mysql-client-4.0.14-0.i386.rpm

MySQL is installed after the directory structure is as follows:

The utility program is---ls/usr/bin/mysql* in the/usr/bin directory

Server program/usr/sbin/mysqld

Data Catalog/var/lib/mysql

By default, MySQL writes error log files, binary log files, and process files in the/var/lib/mysql directory, such as Localhost.err, Localhost.pid, localhost-bin.001, and so on.

To change these conditions, you can modify the/etc/my.cnf file

If you write the log file in the/var/log directory, you can add the following two lines to the my.cnf file:

[Mysqld_safe]

Err-log =/var/log/mysqld.log

There is a utility/usr/bin/mysql_install_db, which can be used to initialize the MySQL database, that is to create the/var/log/mysql directory, and to create a MySQL database (MySQL authorization table and other information) and test database (empty library), If you accidentally delete the/var/log/mysql directory, you can initialize it by using the program.

Uninstall MySQL

Rpm-qa|grep-i MySQL

Rpm-ev mysql-server-4.0.14-0 mysql-client-4.0.14-0

Data and/ETC/MY.CNF in/var/lib/mysql will not be removed after uninstallation, and will be removed manually if determined to be useless.

Rm-f/etc/my.cnf

Rm-rf/var/lib/mysql

MySQL 1130 Error resolution method:

This error occurs when you connect to MySQL via Mysql-front or MySQL administrator

ERROR 1130:host ***.***.***.*** isn't allowed to connect to this MySQL server

Indicates that the connected user account does not have remote connection permissions and can only log on natively (localhost).

You need to change the host entry in the user table in the MySQL database

Rename localhost to%

Specific steps: Login to MySQL

First use MySQL;

There was an error when the update was provided in the other way.

mysql> Update user set host= '% ' where user = ' root ';

ERROR 1062 (23000): Duplicate entry '%-root ' for key ' PRIMARY '

The host information for the following database is then viewed as follows:

Mysql> Select host from user where user = ' root ';

+-----------------------+

| Host |

+-----------------------+

| % |

| 127.0.0.1 |

| Localhost.localdomain |

+-----------------------+

3 Rows in Set (0.00 sec)

The host already has the% value, so run the command directly:

Mysql>flush privileges;

Then connect with MySQL administrator ... Success!!!

tar.gz Version Installation:

Version 1:

1. Place and unzip the MySQL installation package into the/usr/local

Tar zxvf mysql-standard-5.0.27-linux-i686-glibc23.tar.gz

2. Create a symbolic link for a table of contents

Ln-s mysql-standard-4.0.24-pc-linux-gnu-i686 MySQL

3. Build MySQL groups and users

Groupadd MySQL

useradd-g MySQL MySQL

4. Change the user and group of the MySQL directory

Chown-r MySQL. #注意保证此时的当前目录是/usr/lcoal/mysql

Chgrp-r MySQL.

5. Execute configuration script with MySQL user

Su MySQL #切换到mysql用户

Cd/usr/local/mysql #注意切换用户以后, the working directory is not/usr/local/mysql. So we have to go back in.

./configure #执行配置脚本

6. Enter the database to check if the installation was successful

/usr/local/mysql/bin/mysql

If a MySQL prompt appears and enters, the installation is successful!

7. Automatically turn on the MySQL service when the system starts

su-#切换回root用户

Cd/usr/local/mysql

CP Support-files/mysql.server/etc/rc.d/init.d/mysql #把mysql的脚本文件拷到系统的启动目录下

cd/etc/rc.d/init.d/

chmod +x MySQL #改为可执行文件属性

Chkconfig--add MySQL #将mysql加到启动服务列表里

Chkconfig MySQL on #让系统启动时自动打开mysql服务

After restarting the system, execute/usr/local/mysql/bin/mysql, if a MySQL prompt appears indicating that the entire installation was successful

Version 2:

Mysql-standard-4.0.24-pc-linux-gnu-i686.tar.gz is a mysql4.0.24 version of the installation file, is a binary compression package, so our installation method for the binary distribution installation.

Installation steps:

1. Copy the mysql-standard-4.0.24-pc-linux-gnu-i686.tar.gz to a directory

2. Shell> Tar zvxf mysql-standard-4.0.24-pc-linux-gnu-i686.tar.gz

3. The above command will generate a mysql-standard-4.0.24-pc-linux-gnu-i686 folder in the current directory

4. SHELL>MV Mysql-standard-4.0.24-pc-linux-gnu-i686/usr/local/mysql

5. The above command is to mysql-standard-4.0.24-pc-linux-gnu-i686 all the east, cut to/usr/local/mysql under, this step is for the convenience of the future.

6. shell> groupadd MySQL Add a user group named MySQL

7. shell> useradd-g mysql mysql add a user named MySQL to the MySQL user group

If the above two commands cannot be executed, then switch to the root user to execute the

SHELL>SU Root-

8. Shell> Cd/usr/local/mysql

9. shell> CP support-files/my-medium.cnf/etc/my.cnf

This will ask whether to overwrite the duplicate file, answer Y

10.shell> scripts/mysql_install_db--user=mysql

To initialize the database with a MySQL user, the MySQL user must

11.shell> Chown-r Root

Note that the following is a bit, which means that all files in the current directory are set with the owner of the subdirectory

Set as root user

12.shell> chown-r MySQL Data

Indicates that the owner of the data directory under the current directory is set as a MySQL user

13.shell> chgrp-r MySQL.

Note that the following is a bit, which indicates that the file group for the file under the current directory is set to the MySQL group

14.shell> Bin/mysqld_safe--user=root &

If the word "... ended" does not appear, you are done!

15. Enter Display shell>

At this point you can

See if Port 3306 is enabled with the SHELL>NETSTAT–ATLN command

You can also Shell>ps-ef | grep mysqld View the process of mysqld in the current system

or directly shell>bin/mysql–u root into the MySQL client for MySQL operation

Or shell>bin/mysqladmin shutdown stop MySQL service

Remember: At this point your root user does not have a password, any identity can be entered with root, you can

by shell> bin/mysqladmin-u root password ' new password ' to set the root user's password, this password will need to enter the MySQL client and stop the MySQL service

Tip: When starting a single service, you can configure it by modifying the/etc/my.cnf file

You can use the VI editor to open MY.CNF, how to open it, see below

Shell>vi MY.CNF Open MY.CNF

Find the following paragraph

[Mysqld]

Port = 8888

Socket =/tmp/mysql.sock

You can add the appropriate configuration to the following

Log =/var/log/mysql.log

DataDir =/free/mysqldbf

If log =/* Change the location of log save

DataDir =/free/mysqldbf Change the save location of data

I hope I have a little bit of help with friends who meet the same problem

Common commands:

Start MySQL:

Service MySQL Start

/etc/init.d/mysql start

/usr/share/mysql/mysql.server start

[Mysql.server]

# comment out Basedir line, otherwise MySql may not start

# is said to be a MYSQL bug

# Basedir=/var/lib

When root logs on, automatically starts MySQL:

Add 1 lines to the/root/.bash_profile file:

/usr/share/mysql/mysql.server start

To view the boot log:

/var/log/messages

Show MySQL All users:

Use MySQL;

Select Host,user,password from user;

To add a MySQL user (Name:user1,password:sql):

Grant all on * * to [e-mail protected] '% ' identified by ' SQL ' with GRANT option;

To delete a MySQL User:

Delete from user where user= ' user1 ';

To configure environment variables:

Path= $JAVA _home/bin: $CATALINA _home/bin:/usr/local/mysql/bin: $PATH

Linux yum install MySQL and uninstall

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.