构建mysql服务器
构建mysql服务器
1.yum源安装mysql
[root@localhost ~]# yum -y install mysql mysql-server mysql-devel
也可以wget下载源码包安装,创立一个soft的文件夹,使用wget下载,先install wget。
然后再使用wget http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.63.tar.gz
2
3
2.启动mysql,初始化
[root@localhost ~]# /etc/init.d/mysqld restart
4
再重启一下mysql
[root@localhost ~]# /etc/init.d/mysqld restart
5
3.进入mysql
[root@localhost ~]# mysql -uroot -p密码 #初始是没有密码的,这边报错
6
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
报错解决方法
恢复密码,破解密码如下
[root@localhost ~]# /etc/init.d/mysqld stop #先停止mysql
停止 mysqld: [确定]
使用mysqld_safe --skip-grant-tables &跳过权限启动
[root@localhost ~]# mysqld_safe --skip-grant-tables &
[1] 2306
[root@localhost ~]# 180705 00:41:36 mysqld_safe Logging to '/var/log/mysqld.log'.
180705 00:41:36 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
登录mysql,改密码为123456
7
再进行重新启动
[root@localhost ~]# /etc/init.d/mysqld restart
8
4.然后就可以登录mysql
[root@localhost ~]# mysql -uroot -p123456
9
5.
10
创建feiyugame
create database feiyugame;
11
show databases;
create database feiyugame;
use feiyugame
show tables;
create table test01(id varchar(20) name varchar(20));
show tables;
12
desc test01;
insert into test01 values('01' 'feiyugame');
insert into test01 values('02' 'feiyugame02');
show tables;
select * from test01;
13
6.
14
yum安装的mysql存放在/var/lib/mysql
15
授权grant
16
grant all on kinking.* to kinking@'192.168.85.140' identified by "123456";
17
刷新权限
flush privileges;
7.备份,数据库导入导出
〖特别声明〗:本文内容仅供参考,不做权威认证,如若验证其真实性,请咨询相关权威专业人士。如有侵犯您的原创版权或者图片、等版权权利请告知 wzz#tom.com,我们将尽快删除相关内容。