Operating system: Centos6.5 latest mysql version: mysql-5.5.36-linux2.6-i686.tar.gz: Small
Operating system: Centos6.5 latest version
Mysql version: mysql-5.5.36-linux2.6-i686.tar.gz
: Http://mirrors.sohu.com/mysql/MySQL-5.5/
This file is compiled and can be used directly.
1. install Mysql
Groupadd mysql
Useradd-r-g mysql
Cd/home
Tar-zxvf mysql-5.5.36-linux2.6-x86_64.tar.gz
Mv mysql-5.5.36-linux2.6-x86_64 mysql-5.5
Cd/usr/local
Ln-s/home/mysql-5.5 mysql
Cd mysql
Chown-R mysql. (change all user permissions in this directory to mysql users.) note that the following points cannot be lost.
Chgrp-R mysql. (change all user groups in this directory to the mysql User Group)
./Scripts/mysql_install_db -- user = mysql (specify the database permission of the mysql directory as mysql)
Chown-R root.
Chown-R mysql data
Cp support-files/my-medium.cnf/etc/my. cnf (copy the configuration file under the current directory to the system configuration file and rename it my. cnf)
Cp support-files/mysql. server/etc/init. d/mysqld
Chmod + x/etc/init. d/mysqld
Chkconfig -- add mysqld
Chkconfig -- level 345 mysqld on
Service mysqld restart
/Usr/local/mysql/bin/mysqladmin-u root password '000000' (set the password for the root user to log on to mysql)
/Usr/local/mysql/bin/mysql-u root-p (enter and access the mysql database)
2. create a user
// Log on to MYSQL
@> Mysql-u root-p
@> Password
// Create a user
Mysql> insert into mysql. user (Host, User, Password) values ("localhost", "phplamp", password ("1234 "));
// Refresh the system permission list
Mysql> flush privileges;
In this way, a user named: phplamp password: 1234 is created.
Then log on.
Mysql> exit;
@> Mysql-u phplamp-p
@> Enter the password
Mysql> logon successful
3. authorize the user.
// Log on to MYSQL (with ROOT permission ). I log on as ROOT.
@> Mysql-u root-p
@> Password
// Create a database for the user (phplampDB)
Mysql> create database phplampDB;
// Authorize the phplamp user to have all the permissions of the phplamp database.
> Grant all privileges on phplampDB. * to phplamp @ localhost identified by '123 ';
// Refresh the system permission list
Mysql> flush privileges;
Mysql> Other operations
/*
If you want to assign some permissions to a user, you can write as follows:
Mysql> grant select, update on phplampDB. * to phplamp @ localhost identified by '123 ';
// Refresh the system permission table.
Mysql> flush privileges;
*/
4. delete a user.
@> Mysql-u root-p
@> Password
Mysql> delete from user WHERE User = "phplamp" and Host = "localhost ";
Mysql> flush privileges;
// Delete the user's database
Mysql> drop database phplampDB;
4. modify the password of the specified user.
@> Mysql-u root-p
@> Password
Mysql> update mysql. user set password = password ('New password') where User = "phplamp" and Host = "localhost ";
Mysql> flush privileges;