linux cmake编译安装mysql_linux编译安装mysql

3、授权用户

$chown -R mysql:mysql /usr/local/mysql/

$chown -R mysql:mysql /data$chmod 1777 /tmp

4创建my.cnf配置文件

[root@bogon mysql]# cp support-files/my-default.cnf /etc/my.cnf

5.设置环境变量

[root@bogon mysql]# cp support-files/my-default.cnf /etc/my.cnf

cp:是否覆盖"/etc/my.cnf"? y

[root@bogon mysql]# echo'export PATH=/usr/local/mysql/bin:$PATH' >>/etc/profile

[root@bogon mysql]# source!$

source/etc/profile

6.创建服务脚本添加开机启动

[root@bogon mysql]# cp support-files/mysql.server/etc/init.d/mysqld

[root@bogon mysql]# chmod+x /etc/init.d/mysqld [root@bogon mysql]# vim/etc/init.d/mysqld

//服务启动脚本要修改以下两个参数

basedir=/usr/local/mysql //MySQL安装目录

datadir= /data //数据存放目录

a6f2a4fa97f24b4154a1a1dc9e47ec13.png

添加开机启动

[root@bogon mysql]# chkconfig mysqld on

7.初始化数据库

注:到这一步很容易出问题,在初始化的时候一定要加上面的参数,而且在执行这一步操作前/data/mysql/data 这个目录必须是空的;在这里指定的basedir 和 datadir 目录必须要和/etc/my.cnf 配置的目录一直才行。

[root@bogon mysql]# /usr/local/mysql/scripts/mysql_install_db --user=mysql  --basedir=/usr/local/mysql --datadir=/data

26652f3a64f5b7bddd8cd7784daf5092.png

8.启动

[root@bogon mysql]# service mysqld start

Starting MySQL. SUCCESS![root@bogon mysql]# service mysqld status

SUCCESS! MySQL running (29614)

9.登陆和创建用户

[root@bogon mysql]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.6.15 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> show database

-> G

->

-> ;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'database

G' at line 1

mysql> show database;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'database' at line 1

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

| test |

+--------------------+

4 rows in set (0.01 sec)

(1)你想root使用mypassword从任何主机连接到mysql服务器的话。

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

如果你想允许用户myuser从ip为192.168.1.3的主机连接到mysql服务器,并使用mypassword作为密码

GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.3'IDENTIFIED BY'mypassword' WITH GRANT OPTION;

输入命令

FLUSH PRIVILEGES;

新增用户并授权

mysql> grant all privileges on *.* to xueqing @'%' identified by '123456mysql>grant all privileges on *.* to xueqing @'%'identified by'123456'with grant option;

Query OK, 0 rows affected (0.00 sec)

语法:grant all privileges on *.*to 用户名@'%'identified by'密码'withgrant option;

mysql> use test;

Database changed

mysql> show tables;

Empty set (0.00 sec)

mysql> create table xueqing(id int auto_increment,name char(20),primary key(id))engine=myisam default charset=utf8;

Query OK, 0 rows affected (0.01 sec)

10,用mysql图像管理器登陆

fde74c7e04deccb1c7e7144850da5cfc.png

66e7bb849579366157dbcbd037f4a254.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值