Install the latest mysql on centos6

Source: Internet
Author: User
Tags mysql command line yum repolist

Install the latest mysql on centos6
Check whether mysql is installed.

yum list installed |grep mysql
Delete the built-in mysql and its Dependencies
yum -y remove mysql-libs.x86_64
Add a yum source to centos and select a newer source.
1.wget dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm 2.yum localinstall mysql-community-release-el6-5.noarch.rpm3.yum repolist all | grep mysql4.yum-config-manager --disable mysql55-community 5.yum-config-manager --disable mysql56-community6.yum-config-manager --enable mysql57-community-dmr7.yum repolist enabled | grep mysql 
Install mysql Server
 yum install mysql-community-server
Start mysql
service mysqld start
Check whether mysql is self-started and set to enable auto-start
1.chkconfig --list | grep mysqld2.chkconfig mysqld on
Mysql Security Settings
mysql_secure_installation
# Mysql_secure_installation Enter current password for root (enter for none): Press Enter to Set root password? [Y/n] Press enter New password: Login 123456 Re-enter new password: Login 123456 Remove anonymous users? [Y/n] When do I press enter (delete anonymous users) Disallow root login remotely? [Y/n] cannot press enter (remote root login prohibited) Remove test database and access to it? [Y/n] Just press enter (delete test database) Reload privilege tables now? [Y/n] Press ENTER Thanks for using MySQL! # Mysql-u root-p Enter password: 123456 mysql> create database mydb; mysql> grant all privileges on mydb. * to testuser @ localhost identified by '20140901'; mysql> select user, host from mysql. user; mysql> quit
Set the default sequence set
# vi /etc/my.cnf      character-set-server=utf8  # /etc/init.d/mysqld restart  # mysqld --version
About uninstallation
1. Run the following command to check whether the mysql database has been installed on our operating system [root @ xiaoluo ~] # Rpm-qa | grep mysql // This command will check whether the mysql database has been installed on the operating system. 2. if yes, run the rpm-e command or the rpm-e -- nodeps command to uninstall 1. [root @ xiaoluo ~] # Rpm-e mysql // normal deletion Mode 2. [root @ xiaoluo ~] # Rpm-e -- nodeps mysql // strong deletion mode. If the above command is used to delete other dependent files, you can use this command to forcibly delete them. after deletion, run the rpm-qa | grep mysql command to check whether mysql has been uninstalled successfully.
Mysql command 1 for User Creation, authorization, and deletion:
  • Use mysql-u root-p to log on to the mysql Command Line
  • Command: create user 'username' @ 'host' identified by 'Password ';
Description: username-the username you will create, host-specifies the host on which the user can log on. If a local user can use localhost, if you want to allow the user to log on from any remote host, you can use the wildcard %. password-the user's login password. The password can be blank. If it is blank, the user can log on to the server without the password. example: create user 'mysql' @ 'localhost' identified by '000000'; create user 'mysql' @ '2017. 168.1.101 _ 'idendified BY '000000'; create user 'mysql' @ '% 'identified BY '000000'; create user 'mysql' @' % 'identified ''; create user 'mysql' @ '% ';
Ii. Authorization:
  • GRANT privileges ON databasename. tablename TO 'username' @ 'host'
Pri: privileges-operation permissions of users, such as SELECT, INSERT, and UPDATE (for detailed list, see the end of this Article ). use ALL .; databasename-Database Name, tablename-table name. If you want to grant the user the corresponding operation permissions on all databases and tables, it can be represented by *, as shown in *. *. example: grant select, insert on test. user TO 'mysql' @ '%'; grant all on *. * TO 'mysql' @ '%'; note: the user authorized by the preceding command cannot authorize other users. TO authorize the user, run the following command: GRANT privileges ON databasename. tablename TO 'username' @ 'host' with grant option;
3. Set and change user passwords
Command: set password for 'username' @ 'host' = PASSWORD ('newpassword'); if the current login user uses set password = PASSWORD ("newpassword"); example: set password for 'mysql' @ '%' = PASSWORD ("1234 ");
Iv. Revoke User Permissions
  • REVOKE privilege ON databasename. tablename FROM 'username' @ 'host ';
Note: privilege, databasename, tablename-same as the authorization section. example: revoke select on *. * FROM 'mysql' @ '%'; Note: If you authorize the user 'mysql' @ '%' like this (or similar ): grant select on test. user TO 'mysql' @ '%', use revoke select on *. * FROM 'mysql' @ '%'; the command does not cancel the SELECT Operation on the user table in the test database. conversely, grant select on * is used for authorization *. * TO 'msyql '@' % '; then revoke select on test. user FROM 'mysql' @ '%'; the command cannot revoke this user's Select permission on the user table in the test database. FOR more information, run the show grants for 'mysql' @ '%' command.
5. delete a user
Command: drop user 'username' @ 'host ';
View all users in the MYSQL database and have the permission to view all users in the MYSQL database
  • Select distinct concat ('user: "', User,"' @ "', host,"'; ') AS query FROM mysql. user;
View permissions of a specific user in the database
  • Show grants for 'mysql' @ '% ';
View user data table information
  • Select * from mysql. user where user = 'mysql' \ G
To view the structure of a user table, you can use the table structure to query specific items.
  • Desc mysql. user;

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.