Uninstalling, installing, and testing mysql
Mysql uninstall
Yum remove mysql-server mysql-libs compat-mysql51
Rm-rf/var/lib/mysql
Rm/etc/my. cnf
Check whether there is any mysql software:
Rpm-qa | grep mysql
If yes, continue to delete
Install Mysql
1> if there is no installation package locally, you can use the yum command to download it.
# Yum-y install mysql-server
# Yum-y install php-mysql
2> after installation, MySQL is automatically started. by default, there is no user name or password, and a new password is set.
#/Usr/bin/mysqladmin-u root password 'aaaaa'
[Root @ luozhonghua ~] #/Usr/bin/mysqladmin-u root password 'aaaaa'
/Usr/bin/mysqladmin: connect to server at 'localhost' failed
Error: 'Can't connect to local MySQL server through socket '/var/lib/mysql. sock' (2 )'
Check that mysqld is running and that the socket: '/var/lib/mysql. sock' exists!
Solution:
2.1 "/etc/rc. d/init. d/mysqld status to check whether mysql has started
3.2 service mysqld start
3> log on to MySQL
> Mysql-u root-p
Enter password: 'aaaaa'
4> Authorize connected hosts
# Grant select, insert, update, delete on *. * to root@192.168.1.101 identified by 'aaaaa'
Grant select, insert, update, delete on *. * to root@127.0.0.1 identified by 'aaaaa ';
5> Change the default character set
# Cp my-medium.cnf/etc/my. cnf
Add default-character-set = utf8 under [client]
Add default-character-set = utf8 under [mysqld]
Find installation path
Rpm-qa | grep mysql
Rpm-ql package name
[Root @ luozhonghua charsets] # find/usr-name my-medium.cnf
/Usr/share/doc/mysql-server-5.1.73/my-medium.cnf
/Usr/share/mysql/my-medium.cnf.
#6> set mysql to boot automatically
# Vi/etc/rc. local
Add the following line
#/Usr/share/mysql. server start
7> restart MySQL
#/Etc/init. d/mysql restart
Service mysqld restart
8> test;
[Root @ luozhonghua ~] # Mysql-u root-p
Enter password:
Welcome to the MySQL monitor. Commands end with; or/g.
Your MySQL connection id is 3
Server version: 5.1.73 Source distribution
Copyright (c) 2000,201 3, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.
Type 'help; 'or'/h' for help. type'/C' to clear the current input statement.
Mysql> create database xxx
->;
Query OK, 1 row affected (0.06 sec)
Mysql> ls
->;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual th at corresponds to your MySQL server version for the right syntax to use near 'Ls' at line 1
Mysql> show databases
->;
+ -------------------- +
| Database |
+ -------------------- +
| Information_schema |
| Mysql |
| Test |
| Xxx |
+ -------------------- +
4 rows in set (0.06 sec)
Mysql> use xxx;
Database changed
Mysql> show database
->;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual th at corresponds to your MySQL server version for the right syntax to use near 'database' at line 1
Mysql> show databases;
+ -------------------- +
| Database |
+ -------------------- +
| Information_schema |
| Mysql |
| Test |
| Xxx |
+ -------------------- +
4 rows in set (0.01 sec)
Mysql> use xxx;
Database changed
Mysql> create table test (
-> Int id not null,
-> Varchar (20) name null );
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual th at corresponds to your MySQL server version for the right syntax to use near 'Int id not null,
Varchar (20) name null) 'At line 2
Mysql> show tables;
Empty set (0.00 sec)
Mysql> create table dbtest (
-> Id int,
-> Name varchar );
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual th at corresponds to your MySQL server version for the right syntax to use near ')' at line 3
Mysql> create table dbtest (
-> Id int,
-> Name varchar (10 ));
Query OK, 0 rows affected (0.07 sec)
Mysql> show tables;
+ --------------- +
| Tables_in_xxx |
+ --------------- +
| Dbtest |
+ --------------- +
1 row in set (0.01 sec)
Mysql> drop table xxx;
ERROR 1051 (42S02): Unknown table 'XXX'
Mysql> drop table dbtest;
Query OK, 0 rows affected (0.00 sec)
Mysql> ls
->;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual th at corresponds to your MySQL server version for the right syntax to use near 'Ls' at line 1
Mysql> show tables;
Empty set (0.00 sec)
Mysql>