标签:mysql
步骤:function_start_mysql()
{
if [ ! -e "$mysql_sock" ];then
printf "Starting MySQL...\n"
${cmd_path}/mysqld_safe --defaults-file=${mysql_basedir}/${port}/etc/my.cnf &> /dev/null &
else
printf "MySQL is running...\n"
exit
fi
}
function_stop_mysql()
{
if [ ! -e "$mysql_sock" ];then
printf "MySQL is stopped...\n"
exit
else
printf "Stoping MySQL...\n"
${cmd_path}/mysqladmin -u ${mysql_user} -p${mysql_pwd} -S ${mysql_sock} shutdown
fi
}
function_restart_mysql()
{
printf "Restarting MySQL...\n"
function_stop_mysql
sleep 2
function_start_mysql
}
case $1 in
start)
function_start_mysql
;;
stop)
function_stop_mysql
;;
restart)
function_restart_mysql
;;
*)
printf "Usage: ${mysql_basedir}/${port}/bin/mysqld {start|stop|restart}\n"
esac
8、启动服务
a.注意启动服务需要敲上全路径才能启动
/mysqldb/3306/mysqld start|stop|restart
9.连接数据库的方法
a. mysql -S /mysqldb/3306/socket/mysql.sock
b. mysql -S /mysqldb/3307/socket/mysql.sock
c. mysql -S /mysqldb/3308/socket/mysql.sock
10.添加mysql,root密码
a. mysqladmin -uroot -S /mysqldb/3306/socket/mysql.sock password ‘centos‘
b. mysqladmin -uroot -S /mysqldb/3307/socket/mysql.sock password ‘centos‘
c. mysqladmin -uroot -S /mysqldb/3308/socket/mysql.sock password ‘centos‘
11.也可以进入mysql进行更改密码
1、登入mysql
a.mysql -S /mysqldb/3306/socket/mysql.sock
i.查看用户密码表
select user,password,host from mysql.user;
ii.修改添加root密码
update mysql.user set password=password("centos") where user=‘root‘;
iii.删除空账号用户
drop user ‘‘@localhost;
iv.让权限生效
1.flush privileges;
centos-7yum安装(mairadb)实现mysql多实例
标签:mysql
原文地址:http://blog.51cto.com/13466315/2091270