MySQL installation and other operations

Source: Internet
Author: User
Tags mysql client mysql login

Installing the configuration MySQL database in CentOS 6.5 system

Uninstall the original MySQL

Rpm-qa | grep mysql//This command will check if the MySQL database is already installed on the operating system

RPM-E MySQL//normal Delete mode

RPM-E--nodeps MySQL//brute force Delete mode

Rpm-qa | grep mysql//command to see if MySQL has been uninstalled successfully

Note: When we installed MySQL, we did not install the MySQL client, which is the equivalent of installing the MySQL database, and we need to install the Mysql-server service side.

Yum install-y mysql-server MySQL Mysql-deve

After the installation, understand the MySQL database initialization and related configuration

Service mysqld Start// initialize mysql data, we will see that the first time you start the MySQL server will prompt a lot of information, the purpose is to initialize the MySQL database operation, When we restart the MySQL service again, we won't be able to prompt so much information.

Service mysqld Restart

Chkconfig--list | grep mysqld

Chkconfig mysqld on//Set boot up

Mysqladmin-u root password ' root '//Use this command to set the root account password to root

Mysql-u root-p//command to log in to our MySQL database.

The main configuration of the database is as follows:

/ETC/MY.CNF This is the main configuration file for MySQL

/ver/lib/mysql Database file storage location for MySQL database

/var/log mysql database log output storage location

The port number of the MySQL database binding is 3306

NETSTAT-ANP | More

Connecting with Navicat will show a connection error.

Mysql-u root-p

Mysql;use MySQL;   

Mysql;select ' host ' from user where user= ' root ';   

Mysql;update User Set host = '% ' where user = ' root '; # where the execution of this sentence will be an error, whatever it

Mysql;flush privileges;   

Mysql;select ' host ' from user where user= ' root ';

Use Navicat again to Open the connection successfully.

# corresponding to Chinese translation

First sentence: Log in as user root with permissions

Second sentence: Select MySQL library

The third sentence: View the host value of the user table in the MySQL library (hosts/IP names that can be accessed by the connection)

Clause Four: Modify the host value (increase the hostname/IP address with the wildcard%), or you can directly add

Clause five: Refresh MySQL system permissions related table

The sixth sentence: when you re-view the user table, there are modifications.   

Restart the MySQL service to complete.

Forget the MySQL database root user password:

To modify MySQL login settings

Method One:

VI/ETC/MY.CNF
Join: Skip-grant-tables

Restart Mysqld
#/etc/init.d/mysqld Restart

mysql> use MySQL;

mysql> UPDATE user SET Password = Password (' New-password ') WHERE user = ' root ';

Mysql>flush privileges;

Mysql> quit

#vi/etc/my.cnf
Restart Mysqld
#/etc/init.d/mysqld Restart

Method Two:

stop
--skip-grant-tables --skip-networking &
//注意我们加了--skip-networking,避免远程无密码登录MySQL。
# mysql -u root
set password=PASSWORD("mynewpassword") where User=‘root‘;mysql> flush privileges;
mysql > quit
# service mysqld restart
#
mysql -u root -pmynewpassword

Note that -p there can be no spaces between the passwords.

 
 
 
 



 

MySQL installation and other operations

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.