1
2
3
4
5
6
|
tar
zxvf mysql-5.6.14.
tar
.gz
cd
mysql-5.6.14
cmake -DCMAKE_INSTALL_PREFIX=
/usr/local/mysql5
.6 \
-DSYSCONFDIR=
/usr/local/mysql/etc
\
-DMYSQL_DATADIR=
/usr/local/mysql5
.6
/data
make
&&
make
install
|
1
2
3
4
5
6
7
8
9
10
11
12
|
/usr/local/mysql5
.6
/scripts/mysql_install_db
\
--basedir=
/usr/local/mysql5
.6 --datadir=
/usr/local/mysql5
.6
/data
\
--user=mysql&
#初始化数据库
mkdir
-p
/usr/local/mysql5
.6
/etc
cp
support-files
/my-medium
.cnf
/usr/local/mysql/etc/my
.cnf
cp
support-files
/mysql
.server
/etc/rc
.d
/init
.d
/mysqld
chmod
+x
/etc/init
.d
/mysqld
chown
-R root.mysql
/usr/local/mysql/
#赋予mysql属组权限
chown
-R mysql.mysql
/usr/local/mysql/data
#赋予数据存放目录权限
/usr/local/mysql5
.6
/bin/mysqld_safe
–user=mysql&
#安全启动mysql
echo
‘PATH=$PATH:
/usr/local/mysql/bin
' >>
/etc/profile
#设置变量,方便使用mysql命令
source
/etc/profile
|
1
2
3
4
5
6
7
|
vi
/usr/local/mysql/etc/my
.cnf
在[mysqld]下添加
default-character-
set
=utf8
或者 default-character-
set
=gbk
#防止网站出现乱码
在[client]下添加
default-character-
set
=utf8
或者 default-character-
set
=gbk
|
1
2
3
4
5
6
7
8
9
10
11
|
mysqladmin -uroot password
'123.com'
#设置初次登陆mysql密码
mysql -u root -p123456
mysql> show databases;
+——————–+
| Database |
+——————–+
| information_schema |
| mysql |
| test |
+——————–+
6rows inset(
0
.00sec)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
-DCMAKE_INSTALL_PREFIX=
/usr/local/mysql
#安装路径
-DMYSQL_DATADIR=
/usr/local/mysql/data
#数据文件存放位置
-DSYSCONFDIR=
/usr/local/mysql/etc
#my.cnf路径
-DWITH_MYISAM_STORAGE_ENGINE=1
#支持MyIASM引擎
-DWITH_INNOBASE_STORAGE_ENGINE=1
#支持InnoDB引擎
-DWITH_MEMORY_STORAGE_ENGINE=1
#支持MEMORY引擎
-DMYSQL_UNIX_ADDR=
/tmp/mysqld
.sock
#连接数据库socket路径
-DMYSQL_TCP_PORT=3306
#默认端口
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk
#安装需要的字符集
-DDEFAULT_CHARSET=utf8
#默认字符集
-DDEFAULT_COLLATION=utf8_general_ci
#设置默认效验字符集排序规则,要和DDEFAULT_CHARSET一起用
-DMYSQL_USER=mysql
#运行用户
-DWITH_COMMENT=’string’
#注释存储类型
|
1
2
3
|
mysql> show variables like
'character\_set\_%'
;
mysql> show variables like
'char%'
;
mysql> show create table tablename;
#查看创建表时字符集
|