博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
linux下的mysql源码安装
阅读量:4080 次
发布时间:2019-05-25

本文共 4964 字,大约阅读时间需要 16 分钟。

第一次接触mysql,linux下的。以前都是Windows上的,今天有兴趣安装试试环境red hat 6.5 x64mysql5.6.121.下载mysql的源码包http://www.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.12.tar.gz/from/http://cdn.mysql.com/建立mysql用户、安装目录、数据目录[root@pg ~]#  /usr/sbin/groupadd mysql[root@pg ~]#  /usr/sbin/useradd -g mysql mysql[root@pg ~]# mkdir /opt/mysql[root@pg ~]# mkdir -p /opt/mysqldata/data[root@pg ~]# chown -R mysql:mysql /opt/mysql[root@pg ~]# chown -R mysql:mysql /opt/mysqldata/data/[root@pg ~]# su - mysql[mysql@pg ~]$ cd /tmp[mysql@pg tmp]$ tar -xvf mysql-5.6.12.tar.gz [mysql@pg tmp]$cd mysql-5.6.12在进行编译的时候需要用到cmake ,可以有yum直接安装一下,也可以去下载一个cmake安装一下[mysql@pg mysql-5.6.12]$ cmake . -DCMAKE_INSTALL_PREFIX=/opt/mysql -DMYSQL_DATADIR=/opt/mysqldata/data/ -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci关于cmake的一些参数介绍	# -DCMAKE_INSTALL_PREFIX=/opt/mysql         \    #安装路径# -DMYSQL_DATADIR=/opt/mysqldata/data/          \    #数据文件存放位置# -DSYSCONFDIR=/etc                                \    #my.cnf路径# -DWITH_MYISAM_STORAGE_ENGINE=1                   \    #支持MyIASM引擎# -DWITH_INNOBASE_STORAGE_ENGINE=1                 \    #支持InnoDB引擎# -DWITH_MEMORY_STORAGE_ENGINE=1                   \    #支持Memory引擎# -DWITH_READLINE=1                                \    #快捷键功能(我没用过)# -DMYSQL_UNIX_ADDR=/tmp/mysql.sock               \    #连接数据库socket路径# -DMYSQL_TCP_PORT=3306                            \    #端口# -DENABLED_LOCAL_INFILE=1                         \    #允许从本地导入数据# -DWITH_PARTITION_STORAGE_ENGINE=1                \    #安装支持数据库分区# -DEXTRA_CHARSETS=all                             \    #安装所有的字符集# -DDEFAULT_CHARSET=utf8                           \    #默认字符# -DDEFAULT_COLLATION=utf8_general_ci[mysql@pg mysql-5.6.12]$ make [mysql@pg mysql-5.6.12]$ make insatll注意:重新编译时,需要清除旧的对象文件和缓存信息。# make clean# rm -f CMakeCache.txt# rm -rf /etc/my.cnf[mysql@pg mysql-5.6.12]$ make[mysql@pg mysql-5.6.12]$ make install修改my.cnf文件[mysql@pg mysql]$ cp support-files/my-medium.cnf /etc/my.cnf  注意etc的权限[root@pg mysql]$chown -R mysql:mysql /etc/在[mysqld]添加一下内容datadir = /opt/mysqldata/dataport = 3306socket = /tmp/mysql.sockuser=mysql初始化数据库[mysql@pg mysql]$ scripts/mysql_install_db --basedir=/opt/mysql --datadir=/opt/mysqldata/data --user=mysql 启动数据库[mysql@pg mysql]$ ./bin/mysqld_safe --user=mysql &[1] 39498[mysql@pg mysql]$ 170518 15:10:40 mysqld_safe Logging to '/opt/mysqldata/data/pg.err'.170518 15:10:41 mysqld_safe Starting mysqld daemon with databases from /opt/mysqldata/data[mysql@pg bin]$ ./mysql -u mysqlWelcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.6.12 Source distributionCopyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> use test;Database changedmysql> create table a (a int);Query OK, 0 rows affected (0.10 sec)mysql> insert into a value (1);Query OK, 1 row affected (0.03 sec)mysql> insert into a value (2);Query OK, 1 row affected (0.00 sec)mysql> insert into a value (3);Query OK, 1 row affected (0.05 sec)mysql> select * from a;+------+| a    |+------+|    1 ||    2 ||    3 |+------+3 rows in set (0.00 sec)mysql> exitBye如果想使用mysql数据库的话 就得用root用户了mysql@pg bin]$ ./mysql -u rootWelcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 4Server version: 5.6.12 Source distributionCopyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> use mysqlReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> exitBye另一种启动数据库的方式[root@pg mysql]$ cp support-files/mysql.server  /etc/init.d/mysql [root@pg data]# service mysql start[root@pg data]# service mysql stop[root@pg data]#service mysql restart[root@pg data]# service mysql statusMySQL running (39652)                                      [  OK  ][root@pg data]# ps -ef | grep mysqlroot      22609   2260  0 13:40 pts/0    00:00:00 su - mysqlmysql     22610  22609  0 13:40 pts/0    00:00:00 -bashmysql     39498  22610  0 15:10 pts/0    00:00:00 /bin/sh ./bin/mysqld_safe --user=mysqlmysql     39652  39498  0 15:10 pts/0    00:00:04 /opt/mysql/bin/mysqld --basedir=/opt/mysql --datadir=/opt/mysqldata/data --plugin-dir=/opt/mysql/lib/plugin --log-error=/opt/mysqldata/data/pg.err --pid-file=/opt/mysqldata/data/pg.pid --socket=/tmp/mysql.sock --port=3306root      40324   6837  0 16:14 pts/1    00:00:00 grep mysql将mysql的启动服务添加到系统服务中  [root@pg data]chkconfig --add mysql                              #添加系统服务 [root@pg data]chkconfig mysql on                                 #添加开机启动

转载地址:http://lbsni.baihongyu.com/

你可能感兴趣的文章
virbr0 虚拟网卡卸载方法
查看>>
No devices detected. Fatal server error: no screens found
查看>>
新版本的linux如何生成xorg.conf
查看>>
virbr0 虚拟网卡卸载方法
查看>>
Centos 6.0_x86-64 终于成功安装官方显卡驱动
查看>>
Linux基础教程:CentOS卸载KDE桌面
查看>>
db sql montior
查看>>
read humor_campus
查看>>
IBM WebSphere Commerce Analyzer
查看>>
Unix + OS IBM Aix FTP / wu-ftp / proftp
查看>>
my read work
查看>>
db db2 base / instance database tablespace container
查看>>
hd disk / disk raid / disk io / iops / iostat / iowait / iotop / iometer
查看>>
project ASP.NET
查看>>
db db2_monitorTool IBM Rational Performace Tester
查看>>
OS + Unix Aix telnet
查看>>
IBM Lotus
查看>>
Linux +Win LAMPP Tools XAMPP 1.7.3 / 5.6.3
查看>>
my read_university
查看>>
network manager
查看>>