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

鸡蛋学运维-7:mysql服务安装配置

时间:2017-10-13 14:59:18      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:mysql

mysql数据库二进制安装-(mysql-172.16.1.6)

1.创建用户和目录

useradd mysql -s /sbin/nologin -M

mkdir /application

2.下载解压

tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz 

mv mysql-5.5.32-linux2.6-x86_64 mysql-5.5.32

ln -s /application/mysql-5.5.32 /application/mysql

chown -R mysql.mysql /application/mysql

3.初始化数据库

/application/mysql/scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql

4.生成配置文件

cp /application/mysql/support-files/my-small.cnf /etc/my.cnf 

cat /application/mysql/bin/mysqld_safe 

5.修改二进制包启动路径并在后台启动mysql

sed -i ‘s#/usr/local/mysql#/application/mysql#g‘ /application/mysql/bin/mysqld_safe 

/application/mysql/bin/mysqld_safe &

6.修改环境变量

echo $PATH

cp /application/mysql/bin/* /usr/local/sbin/

7.登录测试

mysql

exit

8.配置优化启动方式

cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld

sed -i ‘s#/usr/local/mysql#/application/mysql#g‘ /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld

killall mysql

lsof -i :3306

killall mysqld

lsof -i :3306

netstat -lntup | grep mysql

/etc/init.d/mysqld start

chkconfig mysqld on

chkconfig --list mysqld

9.设置和修改密码

mysqladmin -uroot password "oldboy"

mysqladmin -uroot -poldboy password "123456" 

10.有密码登录命令

mysql -uroot -p123456

mysql -uroot -p

11.mysql简单操作命令

show databases;

use mysql;

show tablesl

select user,host from mysql.user;

select user();

select database();

drop database databasename;

drop user ‘username‘@‘hostname‘;


本文出自 “有压力的鸡蛋” 博客,请务必保留此出处http://78124107.blog.51cto.com/5557978/1972006

鸡蛋学运维-7:mysql服务安装配置

标签:mysql

原文地址:http://78124107.blog.51cto.com/5557978/1972006

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