Linux環境下原始碼編譯方式安裝MySQL5.1(2)
2. 建立資料庫
建立目錄並修改許可權:
[root@mysqldb2 local]# cd /data
[root@mysqldb2 data]# mkdir mysqldata
[root@mysqldb2 data]# cd mysqldata
[root@mysqldb2 mysqldata]# mkdir 3306
[root@mysqldb2 mysqldata]# cd 3306
[root@mysqldb2 3306]# mkdir data binlog tmp innodb_ts innodb_log
[root@mysqldb2 3306]# cd /data
[root@mysqldb2 data]# chown -R mysql:mysql mysqldata建立資料庫:
[root@mysqldb2 local]# cd mysql/
[root@mysqldb2 mysql]# bin/mysql_install_db --user=mysql --datadir=/data/mysqldata/3306/data
Installing MySQL system tables...
OK
Filling help tables...
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:
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h mysqldb2 password 'new-password'
Alternatively you can run:
/usr/local/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 /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/local/mysql/bin/mysqlbug script!編輯和修改my.cnf配置檔案,下列內容僅供參考:
[root@mysqldb2 mysql]# vi /data/mysqldata/3306/my.cnf
[client]
port = 3306
socket = /data/mysqldata/3306/mysql.sock
character-set-server = utf8
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port = 3306
user = mysql
socket = /data/mysqldata/3306/mysql.sock
pid-file = /data/mysqldata/3306/mysql.pid
basedir = /usr/local/mysql
datadir = /data/mysqldata/3306/data
tmpdir = /data/mysqldata/3306/tmp
open_files_limit = 10240
server-id = 303306
lower_case_table_names = 1
character-set-server = utf8
skip-name-resolve
max_connections = 1000
max_connect_errors = 100000
max_allowed_packet = 512M
max_heap_table_size = 1024M
max_length_for_sort_data = 4096
back_log=100
interactive_timeout = 600
wait_timeout = 600
default-storage-engine = InnoDB
net_buffer_length = 8K
sort_buffer_size = 2M
join_buffer_size = 4M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
query_cache_size = 128M
query_cache_limit = 2M
query_cache_min_res_unit = 2k
thread_cache_size = 300
table_open_cache = 1024
tmp_table_size = 256M
#*********** Logs related settings ***********
log-bin = /data/mysqldata/3306/binlog/mysql-bin
binlog_format=row
binlog_cache_size=32m
max_binlog_cache_size=512m
max_binlog_size=512m
long_query_time = 3
log_output = FILE
log-error = /data/mysqldata/3306/mysql-error.log
slow_query_log = 1
slow_query_log_file = /data/mysqldata/3306/slow_statement.log
log_queries_not_using_indexes
general_log = 0
general_log_file = /data/mysqldata/3306/general_statement.log
expire-logs-days = 14
#*********** MyISAM Specific options ***********
key_buffer_size = 32M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
#*********** INNODB Specific options ***********
innodb_file_per_table
transaction-isolation = READ-COMMITTED
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 1024M
innodb_data_home_dir = /data/mysqldata/3306/innodb_ts
innodb_data_file_path = ibdata1:2048M:autoextend
innodb_file_io_threads = 4
innodb_thread_concurrency = 0
innodb_log_buffer_size = 16M
innodb_log_file_size = 256M
innodb_log_files_in_group = 2
innodb_log_group_home_dir = /data/mysqldata/3306/innodb_log
innodb_flush_log_at_trx_commit = 2
innodb_max_dirty_pages_pct = 80
innodb_lock_wait_timeout = 120
innodb_flush_method=O_DIRECT
[mysqldump]
quick
max_allowed_packet = 512M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[myisamchk]
key_buffer_size = 32M
sort_buffer_size = 20M
read_buffer_size = 2M
write_buffer_size = 2M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
open-files-limit = 8192
啟動資料庫:
- [root@mysqldb2 mysql]# mysqld_safe --defaults-file=/data/mysqldata/3306/my.cnf &
設定超級使用者密碼:
- [root@mysqldb2 mysql]# mysqladmin -uroot password 'verysafe' -S /data/mysqldata/3306/mysql.sock
可以通過netstat或ps等命令檢視mysqld是否正常載入,由於預設指定mysqld埠號為3306,因此通過netstat檢視是否存在3306埠即可,例如:
[root@mysqldb2 mysql]# netstat -lnt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:2208 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:864 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:11111 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:16851 0.0.0.0:* LISTEN
0 0 0.0.0.0:21 0.0.0.0:* LISTEN使用mysql命令列連線:
[root@mysqldb2 mysql]# mysql -uroot -pverysafe -S /data/mysqldata/3306/mysql.sock
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 271570
Server version: 5.1.51-junsansi-edition-log Source distribution
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
done~~~
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7607759/viewspace-686342/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Linux環境下原始碼編譯方式安裝MySQL5.1(3)Linux原始碼編譯MySql
- Linux環境下原始碼編譯方式安裝MySQL5.1(1)Linux原始碼編譯MySql
- Linux環境PostGIS原始碼編譯安裝Linux原始碼編譯
- lnmp環境安裝-原始碼編譯LNMP原始碼編譯
- Linux 環境下編譯安裝 RedisLinux編譯Redis
- Linux下原始碼編譯方式安裝MySQL5.5Linux原始碼編譯MySql
- CentOS 7.4 環境下原始碼編譯安裝 postgreSQL 11.4CentOS原始碼編譯SQL
- Android 原始碼的下載和編譯環境的安裝及編譯Android原始碼編譯
- [環境搭建] 透過原始碼編譯安裝 Redis原始碼編譯Redis
- Linux環境下, 原始碼編譯安裝詳解 (編譯CMake 3.15 和 gcc 5.3.0 為例)Linux原始碼編譯GC
- CentOS 7.4 環境下原始碼編譯(多例項)安裝 Mysql 5.7.26CentOS原始碼編譯MySql
- opensuse linux安裝gcc編譯環境LinuxGC編譯
- 從零搭建LNMP環境(一) - 編譯原始碼安裝PHPLNMP編譯原始碼PHP
- Linux下通過原始碼編譯安裝程式Linux原始碼編譯
- 編譯安裝LAMP環境編譯LAMP
- 初始化編譯環境 下載原始碼編譯原始碼
- linux中原始碼編譯安裝Linux原始碼編譯
- CentOS6.9原始碼編譯安裝nginx+php7+mysql環境CentOS原始碼編譯NginxPHPMySql
- 原始碼包安裝mysql5.1原始碼MySql
- Linux 開發環境 -- C/C++開發環境編譯安裝Linux開發環境C++編譯
- Jtti:美國Linux伺服器原始碼編譯的安裝方式JttiLinux伺服器原始碼編譯
- php環境篇:linux編譯安裝nginx1.13.2PHPLinux編譯Nginx
- CPP編譯器安裝(Windows環境)編譯Windows
- linux-原始碼的編譯安裝和解除安裝Linux原始碼編譯
- Linux環境下RPM方式JDK安裝及配置LinuxJDK
- 原始碼編譯安裝Redis原始碼編譯Redis
- LAMP原始碼編譯安裝LAMP原始碼編譯
- Centos7下原始碼編譯安裝apacheCentOS原始碼編譯Apache
- CentOS 6.7下MySQL 5.6原始碼編譯安裝CentOSMySql原始碼編譯
- CentOS 6.7下原始碼編譯安裝MySQL 5.7.5CentOS原始碼編譯MySql
- CentOS 7版本原始碼編譯方式安裝TokuDBCentOS原始碼編譯
- linux下apache+mysql+php開發環境純原始碼編譯搭建(轉)LinuxApacheMySqlPHP開發環境原始碼編譯
- Debian9 (Stretch) 下編譯安裝 LNMP 環境編譯LNMP
- Debian9(Stretch) 下編譯安裝LNMP環境編譯LNMP
- CentOS5.5下快速編譯安裝最新的LAMP環境CentOS編譯LAMP
- Ubuntu環境編譯OpenJDK11原始碼Ubuntu編譯JDK原始碼
- grpc-java原始碼環境編譯RPCJava原始碼編譯
- tomcat原始碼編譯和環境搭建Tomcat原始碼編譯