How to install myql database for linux system in xshell
Ideas:
step
- Install mysql:
1.1 Check the environment before installation, clear related mysql files and configuration files
1.1.1 Check the current installation of mysql, and determine whether there is a myql database
mysql–version 这个是最好的
find / -name mysql 这个来查找文件
ps -ef |grep mysql 这个来看mysql的运行状态
The search results are as follows:
here it means that the myql file exists and is running.
Note: The myql rpm file is not installed here, so you can't use the following statement to check the statement: rpm -qa|grep -i mysql
(This is only for rpm file detection, a bit unreliable) If you
have any questions, you can see this detailed uninstallation of mysql under Linux
1.1. 2 Close the mysql service, delete the myql file found
关闭服务: service mysqld stop
Result: Successfully shut down, if it fails, kill -9 pid process number will be used to shut down
删除文件: rm -rf 文件夹 来删除
Until all mysql-related files are deleted,
finally delete the my.cnf file.
rm -rf /etc/my.cnf
1.2 Install cmake compiler
1.2.1 Install compilation tools and library files
yum -y install gcc gcc-c++ make autoconf libtool-ltdl-devel gd-devel freetype-devel libxml2-devel libjpeg-devel libpng-devel openssl-devel curl-devel bison patch unzip libmcrypt-devel libmhash-devel ncurses-devel sudo bzip2 flex libaio-devel
1.2.2 Install cmake compiler
1 Download method wegt;
install wget statement# yum -y install wget
wget http://www.cmake.org/files/v3.1/cmake-3.1.1.tar.gz
State of normal startup
Picture of failed startup:
The reason is that the widget is not installed. There is no-check-certificate in the prompt of the reason error, which is usually not installed or damaged. re-install.
Download cmake statement:
wget http://www.cmake.org/files/v3.1/cmake-3.1.1.tar.gz
2. Unzip the installation packagetar zxvf cmake-3.1.1.tar.gz
3. Enter the installation package directory cd cmake-3.1.1
4. Compile and install
1 ./bootstrap
2 make && make install
1.3 Install mysql
1. Download address:
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.15.tar.gz
2. Unzip the installation package
tar zxvf mysql-5.6.15.tar.gz
3. Enter the installation package directory cd mysql-5.6.15
4. Compile and install
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/webserver/mysql/ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_INNODB_MEMCACHED=1 -DWITH_DEBUG=OFF -DWITH_ZLIB=bundled -DENABLED_LOCAL_INFILE=1 -DENABLED_PROFILING=ON -DMYSQL_MAINTAINER_MODE=OFF -DMYSQL_DATADIR=/usr/local/webserver/mysql/data -DMYSQL_TCP_PORT=3306
make && make install
5. View the mysql version
/usr/local/webserver/mysql/bin/mysql --version
1.4
mysql configuration 1. Create user mysql for mysql operation:
1 /usr/sbin/groupadd mysql
2 /usr/sbin/useradd -g mysql mysql
2. Create the storage path of binlog and library and grant mysql user permissions
1 mkdir -p /usr/local/webserver/mysql/binlog /www/data_mysql
2 chown mysql.mysql /usr/local/webserver/mysql/binlog/ /www/data_mysql/
3. Create my.cnf configuration file
vim /etc/my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
replicate-ignore-db = mysql
replicate-ignore-db = test
replicate-ignore-db = information_schema
user = mysql
port = 3306
socket = /tmp/mysql.sock
basedir = /usr/local/webserver/mysql
datadir = /www/data_mysql
log-error = /usr/local/webserver/mysql/mysql_error.log
pid-file = /usr/local/webserver/mysql/mysql.pid
lower_case_table_names=1
open_files_limit = 65535
back_log = 600
max_connections = 5000
max_connect_errors = 1000
table_open_cache = 1024
external-locking = FALSE
max_allowed_packet = 32M
sort_buffer_size = 1M
join_buffer_size = 1M
thread_cache_size = 600
#thread_concurrency = 8
query_cache_size = 128M
query_cache_limit = 2M
query_cache_min_res_unit = 2k
default-storage-engine = MyISAM
default-tmp-storage-engine=MYISAM
thread_stack = 192K
transaction_isolation = READ-COMMITTED
tmp_table_size = 128M
max_heap_table_size = 128M
log-slave-updates
log-bin = /usr/local/webserver/mysql/binlog/binlog
binlog-do-db=oa_fb
binlog-ignore-db=mysql
binlog_cache_size = 4M
binlog_format = MIXED
max_binlog_cache_size = 8M
max_binlog_size = 1G
relay-log-index = /usr/local/webserver/mysql/relaylog/relaylog
relay-log-info-file = /usr/local/webserver/mysql/relaylog/relaylog
relay-log = /usr/local/webserver/mysql/relaylog/relaylog
expire_logs_days = 10
key_buffer_size = 256M
read_buffer_size = 1M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
interactive_timeout = 120
wait_timeout = 120
skip-name-resolve
#master-connect-retry = 10
slave-skip-errors = 1032,1062,126,1114,1146,1048,1396
#master-host = 192.168.1.2
#master-user = username
#master-password = password
#master-port = 3306
server-id = 1
loose-innodb-trx=0
loose-innodb-locks=0
loose-innodb-lock-waits=0
loose-innodb-cmp=0
loose-innodb-cmp-per-index=0
loose-innodb-cmp-per-index-reset=0
loose-innodb-cmp-reset=0
loose-innodb-cmpmem=0
loose-innodb-cmpmem-reset=0
loose-innodb-buffer-page=0
loose-innodb-buffer-page-lru=0
loose-innodb-buffer-pool-stats=0
loose-innodb-metrics=0
loose-innodb-ft-default-stopword=0
loose-innodb-ft-inserted=0
loose-innodb-ft-deleted=0
loose-innodb-ft-being-deleted=0
loose-innodb-ft-config=0
loose-innodb-ft-index-cache=0
loose-innodb-ft-index-table=0
loose-innodb-sys-tables=0
loose-innodb-sys-tablestats=0
loose-innodb-sys-indexes=0
loose-innodb-sys-columns=0
loose-innodb-sys-fields=0
loose-innodb-sys-foreign=0
loose-innodb-sys-foreign-cols=0
slow_query_log_file=/usr/local/webserver/mysql/mysql_slow.log
long_query_time = 1
[mysqldump]
quick
max_allowed_packet = 32M
4. Initialize the database
/usr/local/webserver/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --user=mysql
The above syntax error FATAL ERROR: Could not find ./bin/my_print_defaults Cause of the
problem: The file cannot be found in the absolute path during the operation, and the file is changed to the relative path.
Solution: Switch to the installation directory path (/usr/local/webserver/ mysql) under
./scripts/mysql_install_db --defaults-file=/etc/my.cnf --user=mysql
5. Create a boot script
cd /usr/local/webserver/mysql/
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 35 mysqld on
6. Start the mysql server
service mysqld start
The above syntax error The server quit without updating PID file (/usr/local/webserver/mysql/mysql.pid). The
cause of the problem: there is no file mysql.pid in the view path, the mysql owner is root, and the mysql user does not have the creation permission
. : Give mysql the owner of the mysql folder, chown -R mysql:mysql mysql
7. Connect to MySQL
/usr/local/webserver/mysql/bin/mysql -u root -p
There is no password under the root user, press Enter to enter
8. Modify the password:
first log in to MySQL.
Format: mysql> set password for username@localhost = password('new password');
9. Add mysql to the linux environment variable, mysql -u username -p password takes effect
MYSQL_HOME=/usr/local/webserver/mysql
JAVA_HOME=/usr/local/src/jkd1.8
JAVA_BIN=/usr/local/src/jkd1.8/bin
PATH=$JAVA_HOME/bin:$PATH:$MYSQL_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH MYSQL_HOME
10. Connect to external sql software. Open permissions:
grant all on *.* to
'root'@'%' identified by 'root';
11. Other commands
Start: service mysqld start
stop: service mysqld stop
restart: service mysqld restart
Reload configuration: service mysqld reload