1. Modify the etcmy. cnf file default-character-setutf8 [mysqld] datadirvarlibmysqlsocketvarlibmysqlmysql. sockusermysql
I. modify/etc/my. cnf file default-character-set = utf8 [mysqld] datadir =/var/lib/mysqlsocket =/var/lib/mysql. sockuser = mysql
1. Modify the/etc/my. cnf File
Default-character-set = utf8
[Mysqld]
Datadir =/var/lib/mysql
Socket =/var/lib/mysql. sock
User = mysql
# Default to using old password format for compatibility with mysql 3.x
# Clients (those using the mysqlclient10 compatibility package ).
Old_passwords = 1
Default-character-set = utf8 added
[Mysqld_safe]
Log-error =/var/log/mysqld. log
Pid-file =/var/run/mysqld. pid
[Mysql] added
Default-character-set = utf8 added
2. Start Mysql and set the startup of the guest system
Chkconfig mysqld on
Chkconfig -- list mysqld (view system services)
Mysqld 0: off 1: off 2: on 3: on 4: on 5: on 6: off
2-5 is on, OK.
/Etc/rc. d/init. d/mysqld start
3. Set the password
/Usr/bin/mysqladmin-u root password '123'
Iv. Test
1. test if the application password is empty:
Mysql-u root
ERROR 1045 (28000): Access denied for user 'root' @ 'localhost' (using password: NO)
2. Enter the password for testing:
Mysql-u root-p
Enter password:
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 7
Server version: 5.0.77 Source distmysql> ribution
Mysql>
5. Delete Anonymous Users
1. view the user, host, and password list
Select user, host, password from mysql. user;
2. Delete Anonymous Users
Select user, host from mysql. user to view user information
Delete from mysql. user where user = ""; delete Anonymous Users
6. Delete the Test Database
1. show databases; view the database that already exists in the system
2. drop database test;
7. Test Mysql
1. grant all privileges on test. * to CentOSpub @ localhost identified by '000000'; create a user named centosput who has full permission to operate the test database.
2. select user from mysql. user to check whether the user exists
->;
+ ----------- +
| User |
+ ----------- +
| Root |
| Centospub |
| Root |
| Root |
+ ----------- +
3. log out and use centospub to log on to the mysql server.
Exit
Mysql-u centospub-p
Enter password:
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 12
Server version: 5.0.77 Source distribution
Type 'help; 'or' \ H' for help. Type '\ C' to clear the buffer.
4. create database test;
5. show databases; view
6. use test; link to the Database (Database changed)
7. create table test (num int, name varchar (50); create a table
8. show tables; View tables in the database
9. insert into test valuse (1, 'Hello World'); insert a new value.
10. view new inserted values
Select * from test
->;
+ ------ + -------------- +
| Num | name |
+ ------ + -------------- +
| 1 | Hello World! |
+ ------ + -------------- +
11. update test set; update table information
12. View again
Mysql> select * from test
->;
+ ------ + ----------------- +
| Num | name |
+ ------ + ----------------- +
| 1 | Hello Everyone! |
+ ------ + ----------------- +
1 row in set (0.00 sec)
13. delete from test; delete Value
14. drop table test; Delete the test table
15. show tables; view the table and confirm
16. drop database test; Delete the test database
17. show databases; check the database and confirm
8. delete users used for testing
1. log on to the mysql database as the root user.
2. revoke all privileges on *. * from centospub @ localhost; revoke the database operation permissions of centospub users.
3. delete from mysql. user where user = 'centospub 'and host = 'localhost'; delete
4. select user from mysql. user; check and confirm
5. flush privileges; refresh to make it take effect
9. Restart the http service
/Etc/rc. d/init. d/httpd restart