前提是Centos的環境是好的,並且相關的軟體包已經安裝好。 1、創建用戶,並修改創建的數據目錄的屬主 2、安裝需要的依賴軟體 3、上傳源碼包,並解壓安裝 4、進行簡單的配置文件的配置 5、進行安裝初始化 執行結果: 6、啟動mysql,並把相關命令添加到環境變數中 7、進行簡單的mysql的用戶的 ...
前提是Centos的環境是好的,並且相關的軟體包已經安裝好。
1、創建用戶,並修改創建的數據目錄的屬主
[root@bogon ~]# useradd -M mysql -s /sbin/nologin [root@bogon ~]# mkdir /data [root@bogon ~]# chown -R mysql:mysql /data/
2、安裝需要的依賴軟體
[root@bogon ~]# yum -y install gcc gcc-c++ cmake ncurses-devel perl-Data-dumper openssl-devel
3、上傳源碼包,並解壓安裝
[root@bogon ~]# tar -xf mysql-5.6.37.tar.gz -C /usr/local/src/ [root@bogon ~]# cmake \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_DATADIR=/data \ -DWITH_MYISAM_STORAGE_ENGINE=1\ -DWITH_INNOBASE_STORAGE_ENGINE=1\ -DWITH_ARCHIVE_STORAGE_ENGINE=1\ -DWITH_BLACKHOLE_STORAGE_ENGINE=1\ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DENABLED_LOCAL_INFILE=1\ -DDEFAULT_CHARSET=utf8\ -DDEFAULT_COLLATION=utf8_general_ci\ -DEXTRA_CHARSETS=all\ -DMYSQL_TCP_PORT=3306\ -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock\ -DWITH_DEBUG=0 \ -DWITH_SSL=system [root@bogon ~]# make && make install
4、進行簡單的配置文件的配置
[root@bogon etc]# rm -rf my.cnf.d/ [root@bogon support-files]# cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
5、進行安裝初始化
[root@bogon scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/
執行結果:
2018-10-09 22:39:03 37118 [Note] InnoDB: Shutdown completed; log sequence number 1625977 OK Filling help tables...2018-10-09 22:39:03 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2018-10-09 22:39:03 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap. 2018-10-09 22:39:03 0 [Note] /usr/local/mysql//bin/mysqld (mysqld 5.6.37) starting as process 37140 ... 2018-10-09 22:39:03 37140 [Note] InnoDB: Using atomics to ref count buffer pool pages 2018-10-09 22:39:03 37140 [Note] InnoDB: The InnoDB memory heap is disabled 2018-10-09 22:39:03 37140 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2018-10-09 22:39:03 37140 [Note] InnoDB: Memory barrier is not used 2018-10-09 22:39:03 37140 [Note] InnoDB: Compressed tables use zlib 1.2.3 2018-10-09 22:39:03 37140 [Note] InnoDB: Using CPU crc32 instructions 2018-10-09 22:39:03 37140 [Note] InnoDB: Initializing buffer pool, size = 128.0M 2018-10-09 22:39:03 37140 [Note] InnoDB: Completed initialization of buffer pool 2018-10-09 22:39:03 37140 [Note] InnoDB: Highest supported file format is Barracuda. 2018-10-09 22:39:03 37140 [Note] InnoDB: 128 rollback segment(s) are active. 2018-10-09 22:39:03 37140 [Note] InnoDB: Waiting for purge to start 2018-10-09 22:39:03 37140 [Note] InnoDB: 5.6.37 started; log sequence number 1625977 2018-10-09 22:39:03 37140 [Note] RSA private key file not found: /data//private_key.pem. Some authentication plugins will not work. 2018-10-09 22:39:03 37140 [Note] RSA public key file not found: /data//public_key.pem. Some authentication plugins will not work. 2018-10-09 22:39:03 37140 [Note] Binlog end 2018-10-09 22:39:03 37140 [Note] InnoDB: FTS optimize thread exiting. 2018-10-09 22:39:03 37140 [Note] InnoDB: Starting shutdown... 2018-10-09 22:39:04 37140 [Note] InnoDB: Shutdown completed; log sequence number 1625987 OK 其中出現兩個ok是成功的。
6、啟動mysql,並把相關命令添加到環境變數中
初始化之後的說明:
New default config file was created as /usr/local/mysql//my.cnf and will be used by default by the server when you start it. You may edit this file to change server settings WARNING: Default config file /etc/my.cnf exists on the system This file will be read by default by the MySQL server If you do not want to use this, either remove it, or use the --defaults-file argument to mysqld_safe when starting the server 配置文件的問題。 [root@bogon scripts]# mysqld_safe --defaults-file=/usr/local/mysql/my.cnf & [root@bogon scripts]# ps -aux | grep -v grep | grep mysql root 37183 0.0 0.1 113308 1620 pts/0 S 22:46 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my.cnf mysql 37252 0.7 44.8 1325772 449480 pts/0 Sl 22:46 0:01 /usr/local/mysql/bin/mysqld --defaults-file=/usr/local/mysql/my.cnf --basedir=/usr/local/mysql --datadir=/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=bogon.err --pid-file=bogon.pid
7、進行簡單的mysql的用戶的密碼修改。
[root@bogon bin]# mysql -u root mysql> use mysql; mysql> update user set password=PASSWORD("111111") where User='root'; mysql> flush privileges;
8、停止mysql的服務
[root@bogon bin]# mysqladmin -uroot -p shutdown
9、錯誤
編譯錯誤刪除
[root@bogon mysql-5.6.37]# rm -rf CMakeCache.txt