码迷,mamicode.com
首页 > 数据库 > 详细

L001-oldboy-mysql-dba-lesson01

时间:2016-07-07 19:01:00      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:



技术分享

 

 

 

L001-oldboy-mysql-dba-lesson01

 

sql应用重构》经典的书 ,思想,封顶境界!

 

mysql下载页面: http://www.filewatcher.com/m/mysql-5.5.32-linux2.6-x86_64.tar.gz.186722932-0.html


[root@web01 ~]# cd /usr/local/src/

[root@web01 src]# wget http://101.44.1.120/files/2141000004483B18/cdn.mysql.com//archives/mysql-5.5/mysql-5.5.32-linux2.6-x86_64.tar.gz

 

[root@web01 src]# tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz

[root@web01 src]# cp -R mysql-5.5.32-linux2.6-x86_64 /usr/local/mysql

[root@web01 src]# ll /usr/local/mysql

 

 

[root@web01 ~]# cp /usr/local/mysql/support-files/my-huge.cnf /etc/my.cnf

 

[root@web01 ~]# mkdir /var/lib/mysql

[root@web01 ~]# mv /etc/my.cnf /var/lib/mysql/

[root@web01~]# vi /var/lib/mysql/my.cnf +40

21 default-character-set = utf8

40 datadir = /var/lib/mysql

41 character_set_server = utf8

139 default-character = utf8

 

[root@web01 ~]# useradd -M -s /sbin/nologin mysql

[root@web01 ~]# id mysql

[root@web01 ~]# chown -R mysql:mysql /var/lib/mysql/

 

[root@web01~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

[root@web01 mysql]# cd /usr/local/mysql

[root@web01 mysql]# ./scripts/mysql_install_db --user=mysql

[root@web01~]#

/usr/local/mysql/scripts/mysql_install_db  --defaults-file=/var/lib/mysql/my.cnf --user=mysql  #mysql初始化

[root@web01 ~]#

echo ‘/usr/local/mysql/bin/mysqld_safe --defaults-file=/var/lib/mysql/my.cnf &‘ >>/etc/rc.local

 

[root@web01 ~]#

/usr/local/mysql/bin/mysqld_safe --defaults-file=/var/lib/mysql/my.cnf &

[root@web01 ~]# ps -ef|grep mysql

#或者使用/etc/init.d来启动mysql

[root@web01 ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

 

[root@web01 ~]# tailf /var/lib/mysql/web01.com.err  #启动后,这个日志一定要好好看看。

 

[root@web01 ~]# ln -s /usr/local/mysql/bin/mysqladmin /bin/mysqladmin

[root@web01 ~]# ln -s /usr/local/mysql/bin/mysqldump /bin/mysqldump

[root@web01 ~]# ln -s /usr/local/mysql/bin/mysql /bin/mysql

[root@web01 ~]# ln -s /usr/local/mysql/bin/mysqld_safe /bin/mysqld_safe

[root@web01 ~]# ln -s /usr/local/mysql/bin/mysqlbinlog /bin/mysqlbinlog


[root@web01 ~]# mysql -u root -S /tmp/mysql.sock

mysql>

use mysql;

show tables;

select * from user\G;

 

[root@web01 ~]# mysqladmin -u root password ‘testpassword‘   #设置root密码

[root@web01 ~]# mysql -uroot -ptestpassword

mysql> select user,host,password from mysql.user;

delete from mysql.user where user=‘root‘ and host=‘web01.com‘;

delete from mysql.user where user=‘root‘ and host=‘::1‘;

use mysql; update user set password=‘*9F69E47E519D9CA02116BF5796684F7D0D45F8FA‘ where host=‘127.0.0.1‘;

select user,host,password from mysql.user; 

+------+-----------+-------------------------------------------+

| user | host      | password                                  |

+------+-----------+-------------------------------------------+

| root | localhost | *9F69E47E519D9CA02116BF5796684F7D0D45F8FA |

| root | 127.0.0.1 | *9F69E47E519D9CA02116BF5796684F7D0D45F8FA |

+------+-----------+-------------------------------------------+

 

create database mywebsite;

show databases;

grant all on mywebsite.* to ‘test‘@‘10.0.0.%‘ identified by ‘test‘;

flush privileges;

show global variables like ‘%char%‘; 

select user,host,password from mysql.user;

+------+-----------+-------------------------------------------+

| user | host      | password                                  |

+------+-----------+-------------------------------------------+

| root | localhost | *9F69E47E519D9CA02116BF5796684F7D0D45F8FA |

| root | 127.0.0.1 | *9F69E47E519D9CA02116BF5796684F7D0D45F8FA |

| test | 10.0.0.%  | *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29 |

+------+-----------+-------------------------------------------+

 

update mysql.user set password=password(‘newpassword‘) where user=‘test‘;

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 





附件列表

     

    L001-oldboy-mysql-dba-lesson01

    标签:

    原文地址:http://www.cnblogs.com/bolinzhihua/p/5650765.html

    (0)
    (0)
       
    举报
    评论 一句话评论(0
    登录后才能评论!
    © 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
    迷上了代码!