加入收藏 | 设为首页 | 会员中心 | 我要投稿 财气旺网 - 财气网 (https://www.caiqiwang.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

CentOS下mysql 卸载 安装 测验全过程

发布时间:2022-07-05 11:48:38 所属栏目: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
  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
  
  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> 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)

(编辑:财气旺网 - 财气网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!