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>

相关内容

热门资讯

iOS 26.5更新苹果地图两... 苹果地图是iOS 26.5此次更新中获得新功能的应用之一。以下是地图用户需要了解的最新变化。 推荐...
每经热评 | 黄仁勋喝蜜雪冰城... 每经评论员 朱成祥 黄仁勋近期到访北京,被拍到在胡同喝豆汁、吃炸酱面、举着蜜雪冰城饮料。他表情轻松,...
我省3项目被列入工信部先进计算... 本报太原5月15日讯(记者王蕾)近日,工业和信息化部公布了2025年先进计算赋能新质生产力典型应用案...
薛贵:学习的革命——脑科学与人... 1 学习的本质不是知识的装卸, 而是雕刻大脑的“芯片” 耶鲁大学前校长理查德·查尔斯·莱文曾说过:如...
伊朗:已制定管理霍尔木兹海峡指... 新华社德黑兰5月16日电 伊朗伊斯兰议会国家安全和外交政策委员会主席易卜拉欣·阿齐兹16日在社交媒体...
微纳星空双星成功入轨!迈入批产... 来源:北京日报客户端 5月15日12时33分,由海淀企业北京微纳星空科技股份有限公司研制的泰景三号0...
摆拍盲道被撞,反对“愤怒诱饵”... □李琛5月16日,据北京警方通报:刘某(男,26岁)和江某某(女,24岁)为吸粉引流、博取关注、牟取...
原创 这... 此次美高层行程中,随行团队中两位华裔面孔格外引人注目。一位是AI领域的重量级人物黄仁勋,自带科技光环...
联合国教科文组织总干事阿纳尼一... 5月14日下午,联合国教科文组织总干事阿纳尼一行到访张江人工智能创新小镇AI应用商店。 上海于20...
小米Air手机曾接近量产 上市... 快科技5月16日消息,卢伟冰在今晚直播聊手机产品规划时,透露一个重磅内幕,小米其实早就规划过对标苹果...