創建mysql組:
groupadd mysql
創建mysql用戶並賦予這個mysq組中,不創建家目錄,不允許用戶登錄。(因爲剛剛創建的mysql是虛擬用戶,所以不允許登錄)
useradd mysql -g mysql -M -s /bin/nologin
源碼安裝mysql
解壓後進行編譯安裝:
./configure \
--prefix=/application/mysql5.1.72 \
--with-unix-socket-path=/application/mysql5.1.72/tmp/mysql.sock \
--localstatedir=/application/mysql5.1.72/data \
--enable-assembler \
--enable-thread-safe-client \
--with-mysqld-user=mysql \
--with-big-tables \
--without-debug \
--with-pthread \
--enable-assembler \
--with-extra-charsets=complex \
--with-readline \
--with-ssl \
--with-embedded-server \
--enable-local-infile \
--with-plugins=partition,innobase \
--with-mysqld-ldflags=-all-static \
--with-client-ldflags=-all-static
make && make make install
安裝好後 創建mysql的軟鏈接:
ln -s /application/mysql5.1.72/ /application/apache
在該目錄下查看/usr/local/tools/mysql-5.1.72/support-files/下面cnf的配置文件 這些文件都是默認的配置文件的模版,適合與不同的場景
[root@node1 support-files]# ll my*.cnf
-rw-r--r-- 1 root root 4746 05-04 02:49 my-huge.cnf 第四小 這些是根據服務器的硬件配置來衡量,服務器硬件過低,用最小的,配置高,用最大
-rw-r--r-- 1 root root 19779 05-04 02:49 my-innodb-heavy-4G.cnf 最大的
-rw-r--r-- 1 root root 4720 05-04 02:49 my-large.cnf 第三小
-rw-r--r-- 1 root root 4731 05-04 02:49 my-medium.cnf 最小的
-rw-r--r-- 1 root root 2499 05-04 02:49 my-small.cnf 第二小
然後將其中選擇適合你的服務器的配置文件拷貝到/etc下
[root@node1 support-files]# cp my-small.cnf /etc/my.cnf
創建mysql數據庫存放數據的目錄:
[root@node1 ~]# mkdir /application/mysql/data -p
給/application/mysql/目錄授予mysql用戶和mysql組的權限
[root@node1 ~]# chown -R mysql.mysql /application/mysql/
初始化數據文件
[root@node1 ~]#/application/mysql/bin/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
plication/mysql/data/ --user=mysql
Installing MySQL system tables...
170504 4:34:50 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
OK
Filling help tables...
170504 4:34:50 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/application/mysql//bin/mysqladmin -u root password 'new-password'
/application/mysql//bin/mysqladmin -u root -h node1.com password 'new-password'
Alternatively you can run:
/application/mysql//bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /application/mysql/ ; /application/mysql//bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /application/mysql//mysql-test ; perl mysql-test-run.pl
Please report any problems with the /application/mysql//scripts/mysqlbug script!
現在mysql就已經安裝完成,到data目錄下查看會生成兩個庫:
[root@node1 ~]# ll /application/mysql/data/
總計 8
drwx------ 2 mysql root 4096 05-04 04:34 mysql 系統的庫,
drwx------ 2 mysql root 4096 05-04 04:34 test 測試的庫,建議刪除,不安全。
[root@node1 init.d]# /application/mysql//bin/mysqld_safe &
[1] 17071
[root@node1 init.d]# 170504 04:48:46 mysqld_safe Logging to '/application/mysql5.1.72/data/node1.com.err'.
170504 04:48:47 mysqld_safe Starting mysqld daemon with databases from /application/mysql5.1.72/data
[root@node1 init.d]#
[root@node1 init.d]#
[root@node1 init.d]#
[root@node1 init.d]#
[root@node1 init.d]#
[root@node1 init.d]# netstat -tulnp | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 17179/mysqld
啓動mysql 以start方式啓動
[root@node1 init.d]# cp /usr/local/tools/mysql-5.1.72/support-files/mysql.server /etc/init.d/mysqld
[root@node1 init.d]# chmod +x /etc/init.d/mysqld
保存之後就可以啓動了。
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.00 sec)
mysql> drop database test;
Query OK, 0 rows affected (0.01 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
+--------------------+
2 rows in set (0.00 sec)
mysql> select user,host from mysql.user;
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| | localhost |
| root | localhost |
| | node1.com |
| root | node1.com |
+------+-----------+
5 rows in set (0.00 sec)
mysql> drop user ""@localhost
-> ;
Query OK, 0 rows affected (0.00 sec)
mysql> drop user ""@node1.com
-> ;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql>
mysql> select user,host from mysql.user;
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | localhost |
| root | node1.com |
+------+-----------+
3 rows in set (0.00 sec)
源碼安裝mysql
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
MySQL数据库集群-PXC方案
wy53780
2020-04-23 13:55:07
sql語法、關係建模
死瘦宅
2019-02-24 22:35:22
MySQL 事務、函數、觸發器、數據庫備份、權限管理
死瘦宅
2019-02-24 22:35:12
《從0到1學習Flink》—— Flink 讀取 Kafka 數據批量寫入到 MySQL
zhisheng
2019-02-24 21:04:11
SpringBoot 填坑 (一) | CentOS7.4 環境下,表時間字段默認值設置失效
一個優秀的廢人
2019-02-24 15:33:55
mysql-存儲過程
雙子城
2019-02-24 13:43:57
jmeter學習指南之操作 mysql 數據庫
小強測試
2019-02-24 13:34:06
20190222全天的實驗
清歡難尋
2019-02-24 13:17:21
數據庫監控:zabbix(fpmmm)
AMGYM
2019-02-24 13:05:14
數據庫監控:nagios(check_mysql_health)
AMGYM
2019-02-24 13:05:14
如何釋放已刪除的InnoDB磁盤空間
lvrenX
2019-02-24 13:04:33
MYSQL中視圖的使用
雙子城
2019-02-24 08:44:17
MySQL從刪庫到跑路
司木
2019-02-24 00:24:07
JavaBean操作
yi_sixian
2019-02-23 14:05:20
fdb2b技術博客簡介
fdb2b
2019-02-23 14:01:03