鸡蛋学运维-7:mysql服务安装配置
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了鸡蛋学运维-7: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服务安装配置的主要内容,如果未能解决你的问题,请参考以下文章