Home > Database > Mysql Tutorial > linux下使用yum安装mysql详解_MySQL

linux下使用yum安装mysql详解_MySQL

WBOY
Release: 2016-06-01 13:01:05
Original
1302 people have browsed it

本人博客上一篇(http://blog.csdn.net/tjcyjd/article/details/41646889)已讲了yum源的配置,有了yum那么安装mysql就会很简单,具体如下:

1、安装客户端和服务器端

确认mysql是否已安装:
yum list installed mysql*
rpm -qa | grep mysql*
Copy after login
查看是否有安装包:
yum list mysql*
Copy after login
安装mysql客户端:
yum install mysql
Copy after login
安装mysql 服务器端:
yum install mysql-server
yum install mysql-devel
Copy after login

2、启动、停止设置

数据库字符集设置
mysql配置文件/etc/my.cnf中加入default-character-set=utf8
启动mysql服务:
service mysqld start
Copy after login
或者/etc/init.d/mysqld start
设置开机启动:
chkconfig -add mysqld
Copy after login

查看开机启动设置是否成功

chkconfig --list | grep mysql*
Copy after login

mysqld 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
停止mysql服务:
service mysqld stop
Copy after login

3、登录及忘记修改密码

创建root管理员:
mysqladmin -u root password 666666
Copy after login
登录:
mysql -u root -p
如果忘记密码,则执行以下代码
service mysqld stop
mysqld_safe --user=root --skip-grant-tables
mysql -u root
use mysql
update user set password=password("666666") where user="root";
flush privileges;
Copy after login

4、允许远程访问设置

开放防火墙的端口号
mysql增加权限:mysql库中的user表新增一条记录host为“%”,user为“root”。
use mysql;
UPDATE user SET `Host` = '%' WHERE `User` = 'root' LIMIT 1;
Copy after login
%表示允许所有的ip访问


5、mysql的几个重要目录

(a)数据库目录
/var/lib/mysql/
(b)配置文件
/usr/share /mysql(mysql.server命令及配置文件)
(c)相关命令
/usr/bin(mysqladmin mysqldump等命令)
(d)启动脚本
/etc/rc.d/init.d/(启动脚本文件mysql的目录)
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template