每次安装使用mysql都折腾很长时间,这次折腾完毕,把最简单的安装使用记录下来,叫懒人mysql
yum 安装mysql
1.下载mysql的repo源
$ wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
2. 安装mysql-community-release-el7-5.noarch.rpm包
$ sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
安装这个包后,会获得两个mysql的yum repo源:
/etc/yum.repos.d/mysql-community.repo
/etc/yum.repos.d/mysql-community-source.repo
3. 安装mysql
$ sudo yum install mysql-server mysql-client libmysqlclient-dev mysql-devel MySQL-python
4.初始化mysql
$ mysql_install_db
简单使用mysql
1.设置root密码
登陆mysql:
$ mysql -u root
设置密码
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');
2.创建数据库
CREATE DATABASE `testDB` DEFAULT CHARACTER SET utf8
3.创建用户并最大权限:
CREATE USER test@'%' IDENTIFIED BY 'test';
grant all privileges on testDB.* to test@'%' IDENTIFIED BY 'test';
网友评论