当前位置: 首页 >数据库 > linux mysql 卸载,安装,測试全过程

linux mysql 卸载,安装,測试全过程

 Mysql卸载
yum remove mysql mysql-server mysql-libs compat-mysql51
rm -rf /var/lib/mysql
rm /etc/my.cnf
查看是否还有mysql软件:
rpm -qa|grep mysql
有的话继续删除


Mysql安装
1>若本地没有安装包 能够考虑使用yum命令进行下载
# yum -y install mysql-server
# yum -y install php-mysql
2>安装后,MySQL自己主动启动,默认没实useame和password,设置新password
#   /usr/bin/mysqladmin -u root password 'aaaaaa'
[root@luozhonghua ~]#   /usr/bin/mysqladmin -u root password 'aaaaaa'
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
解决:
2.1》/etc/rc.d/init.d/mysqld status 看看mysql是否已经启动
3.2》service mysqld start
3>登录MySQL
>mysql -u root -p
enter password:’aaaaaa’


4>赋权连接的主机
#grant select,insert,update,delete on *.* to root@192.168.1.101  identified by 'aaaaaa'
grant select,insert,update,delete on *.* to root@127.0.0.1  identified by 'aaaaaa';




5>更改默认字符集
# cp my-medium.cnf  /etc/my.cnf
在[client]下增加 default-character-set=utf8
在[mysqld]下增加 default-character-set=utf8
查找安装路径
Rpm -qa | grep mysql
Rpm -ql 包名
[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>设置mysql开机自启动
# vi /etc/rc.local
增加例如以下一行
#/usr/share/mysql/mysql.server start
7>又一次启动MySQL
# /etc/init.d/mysql restart
service mysqld restart


8>測试;


[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, 2013, 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>

作者:zhchoutai
来源链接:https://www.cnblogs.com/zhchoutai/p/7244723.html

版权声明:
1、JavaClub(https://www.javaclub.cn)以学习交流为目的,由作者投稿、网友推荐和小编整理收藏优秀的IT技术及相关内容,包括但不限于文字、图片、音频、视频、软件、程序等,其均来自互联网,本站不享有版权,版权归原作者所有。

2、本站提供的内容仅用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯相关权利人及本网站的合法权利。
3、本网站内容原作者如不愿意在本网站刊登内容,请及时通知本站(javaclubcn@163.com),我们将第一时间核实后及时予以删除。





本文链接:https://www.javaclub.cn/database/118554.html

标签:SQL_syntax
分享给朋友:

“linux mysql 卸载,安装,測试全过程” 的相关文章