CentOS下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‘
[[email protected] ~]# /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 [email protected] identified by ‘aaaaaa‘
grant select,insert,update,delete on *.* to [email protected] 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 包名
[[email protected] 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>测试;

[[email protected] ~]# 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>

时间: 2024-10-12 10:18:44

CentOS下mysql 卸载,安装,测试全过程的相关文章

CentOS下MySQL数据库安装

前辈们总是说,要边学边记录,要总结.所以,开始把每天学到的内容一点一点记录. 复杂的理论不懂,只会目前安装,安好后就开始玩咯! 1.在官网下载相应的rpm安装包 下载地址:http://dev.mysql.com/downloads/mysql/5.6.html#downloads 比如:我只下载了这三个. 2.鄙人就用rpm命令安装(相对较熟悉) 其实,这是应该是第3步 #rpm -ivh MySQL-client-5.6.19-1.el6.i686.rpm #rpm -ivh MySQL-d

centos下mysql 数据库安装、调试

博主是一个linux的初学者,决定记录学习过程中的点滴,当做一个成长记录也好,当做后来人学习的参考也罢,总之,博客就在那里,我们各取所需,只是不要让他孤独就好. 首先,持久化数据是一个程序必备的模块,恰逢博主的项目中也需要在centos操作系统上部署,所以就以安装mysql数据库开始吧.可能你觉得内容比较简单,但无所谓吧,会者谓之简单:不会者谓之难.博主只求用最简单的描述,满足“不会者”的好学. 主要分为两种方式,一种是下载安装包,然后安装:一种是通过yum命令.博主觉得通过yum命令比较简单,

Linux(centos)下mysql编译安装教程

Linux下mysql编译安装教程 #查看linux发行版本号 cat /etc/issue #查看linux内核版本 uname -r 本文测试环境centOS6.6 一.Linux下编译安装MySQL前的准备工作 在线安装编译源码所需的工具和库(无法联网的话要事先准备软件,或者系统盘) yum install gcc gcc-c++ ncurses-devel perl 从mysql5.5起源代码编译需要借助cmake这款编译工具.从http://www.cmake.org下载cmake源码

centos下mysql的安装和配置

我是通过yum来进行安装的,方便快捷 1.yum install -y mysql-server 等待安装完成即可 2.chkconfig mysqld on 设置MySQL服务随系统启动自启动 3.[root@local ~]# chkconfig --list mysqld 确认MySQL自启动 mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off   如果2--5为on的状态就OK 4./etc/rc.d/init.d/mysqld start 启动My

Linux系统CentOS下mysql的安装日志

今天自己捣鼓了一下,在linux系统CentOs6.5下使用源码方式安装和配置mysql,这里记录一下步骤. a) 下载mysql,source版本.Mysql-5.6.20.tar.gz b) 安装编译源码所需的工具和库 yum install gcc gcc-c++ ncurses-devel perl c) 安装cmake   wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz tar -xzvf cmake-2.8.10.

CentOS下mysql默认安装位置

如果采用RPM包安装,安装路径应在/usr/share/mysql目录下 mysqldump文件位置:/usr/bin/mysqldump mysqli配置文件: /etc/my.cnf或/usr/share/mysql/my.cnf mysql数据目录在/var/lib/mysql目录下 如果采用源代码安装,一般默认安装在/usr/local/mysql目录下

centos下mysql的安装及数据库存储目录迁移

wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm rpm –ivh mysql57-community-release-el7-8.noarch.rpm yum install mysql-server 进入/etc 编辑my.cnf 在最后一行加上 skip-grant-tables 跳过MySQL密码验证 service mysqld restart 重启数据库 mysql -u root 直接进入数据

centos下mysql 最新版终于安装成功!备份一下几个关键地方

我本来只是为了搭建简单的LAMP环境,亲自动手,却发现有这么多的问题会发生.(by default7#zbphp.com) 很多地方给的安装Mysql的提示是通过yum一键安装.shell命令如下: yum install mysql yum install mysql-server yum install mysql-devel 但是,这个命令安装的mysql版本很旧,5.1.0x版本的,官网的Mysql已经是 5.6.x版本了.太旧了,记得08年的时候就出了 5.1的版本了. 坚持安装最新版

Linux下mysql的安装与卸载并且连接navicat详解(亲测可用)

哈喽,大家好,费了九牛二虎之力,终于完成了linux下用yum安装mysql,虽然出了很多错,但是最终成功可谓是不易,下面详细介绍下mysql的安装步骤: 一.卸载mysql 1.首先查看以前是否在linux上安装过mysql,如果有则需要先卸载干净. 首先使用命令查看虚拟机上是否存在mysql rpm -qa|grep -i mysql 如图所示,表示存在 2.停止mysql服务.删除之前安装的mysql 删除命令:rpm -e –nodeps 包名 如图所示: 如果提示依赖包错误,则使用以下