CentOS下mysql 卸载,安装,测试全过程
admin
2023-05-17 12:22:16
0

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自动启动, 【linux教程】 ,默认没有用户名和密码,设置新密码
# /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>

相关内容

热门资讯

伊朗外长:与阿曼谈判接近完成 △伊朗外交部长阿拉格齐(中)当地时间8月2日,伊朗外交部长阿拉格齐在政府内阁会议上介绍伊朗与阿曼谈判...
河南2026年“三支一扶”计划... 针对近期备受关注的2026年河南省“三支一扶”计划招募相关舆情,河南省“三支一扶”领导小组协调办公室...
以卵击石的“汉光演习”不过是一... 昨天题为《人民解放军越强大,台海和平越有保障》的海风文章,已经反映了一部分台海局势的现实。若再把8月...
美国一养老社区将推出面向老人的... 据《独立报》8月1日报道,美国亚利桑那州一养老社区将引入一台专为老年人设计的大麻自助售卖机,居民无需...
“你头发都白了”,同守广西边防... “你头发都白了,模样还是没变,就是没有年轻时候那么帅了。”
小米手机再度涨价:旗舰最高上涨... 8月2日,小米商城价格更新,多款主力机型上调300元至500元不等。其中,REDMI Turbo 5...
“真实社交”售卖“优先访问权”... 据了解,购买这项服务的企业能够直接接入“真实社交”数据源,辅以人工智能技术解读信息,进而提前把握市场...
原创 狂... 英伟达正式官宣与 Safe Superintelligence(SSI)达成长期战略合作,总投资规模...
马斯克最新预言来了,钱要没用了... “以法莲是商人,手里有诡诈的天平,爱行欺骗!”——圣经 据红星新闻报道,本月,埃隆·马斯克在接受专...
遭欧盟22国“围攻”,西班牙怒... 西班牙首相桑切斯与22个欧盟成员国领导人激烈交锋后,由轮值主席国爱尔兰正式召集,欧盟将于本周二(8月...