一、 查看系统自带mysql是否已安装。mysql
[root@develop bin]# yum list installed | grep mysqllinux
mysql-libs.x86_64 5.1.73-5.el6_6 @base sql
二、 如有自带安装的mysql,将其卸载数据库
[root@develop ~]# yum –y remove mysql-libs.x86_64centos
如有多个依赖文件则依次卸载。服务器
三、 使用yum安装mysql数据库。ide
[root@develop ~]# yum -y install mysql-server mysql mysql-develui
命令将:mysql-server、mysql、mysql-devel都安装好,当结果显示为“Complete!”即安装完毕。spa
注:安装mysql只是安装了数据库,只有安装mysql-server才至关于安装了客户端。.net
四、 启动mysql服务,在终端输入:
service mysqld start或者/etc/init.d/mysqld start
五、 设置MySQL服务随系统启动自启动
[root@develop ~]# chkconfig mysqld on
检查启动状态
[root@develop ~]# chkconfig --list mysqld
mysqld 0:关闭1:关闭2:启用3:启用4:启用5:启用6:关闭
六、 查看刚安装mysql数据库版本信息
[root@develop ~]# rpm -qi mysql-server
Name : mysql-server Relocations: (not relocatable)
Version : 5.1.73 Vendor: CentOS
Release : 5.el6_6 Build Date: 2015年06月22日 星期一 21时08分32秒
Install Date: 2015年12月23日 星期三 11时00分00秒 Build Host: c6b9.bsys.dev.centos.org
Group : Applications/Databases Source RPM: mysql-5.1.73-5.el6_6.src.rpm
Size : 25882979 License: GPLv2 with exceptions
Signature : RSA/SHA1, 2015年06月22日 星期一 22时30分08秒, Key ID 0946fca2c105b9de
Packager : CentOS BuildSystem <http://bugs.centos.org>
URL : http://www.mysql.com
Summary : The MySQL server and related files
Description :
MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
client/server implementation consisting of a server daemon (mysqld)
and many different client programs and libraries. This package contains
the MySQL server and some accompanying files and directories.
七、 建立root管理用户
查看文件安装路径
[root@develop ~]# whereis mysql
mysql: /usr/bin/mysql /usr/lib64/mysql /usr/include/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz
在终端输入:cd /usr/bin/ 目录下 建立root用户密码
[root@develop bin]# mysqladmin -u root -p password 密码
八、 登陆mysql系统
[root@develop bin]# mysql -uroot -p
Enter password: [输入原来密码]
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 23
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
九、建立远程用户
使用grant语句添加:首先在数据库本机上用root用户
登陆mysql(我是用远程控制linux服务器,至关于在服务器本机登陆mysql了),而后输入:
mysql>grant all privileges on *.* to admin@localhost identified by 'something' with grant option;
添加一个用户admin并受权经过本地机(localhost)访问,密码"something"。
mysql>grant all privileges on *.* to admin@"%" identified by 'something' with grant option;
添加一个用户admin并受权可从任何其它主机发起的访问(通配符%)。使用这一条语句便可。