공식 홈페이지에서 mysql-5.6.12-linux-glibc2.5-x86_64.tar.gz를 다운로드하세요
mysql 사용자 생성
[root@Master home]# useradd mysql [root@Master data]# echo 'mysql'|passwd --stdin mysql
mysql 사용자의 비밀번호를 변경하세요.
passwd: 모든 인증 토큰이 성공적으로 업데이트되었습니다.
mysql 사용자 생성 이유
mysql을 사용하지 않으면 오류가 발생합니다. 여러 번 시도하면 mysql 사용자가 성공적으로 추가되었습니다.
* 물론 일상적인 작업을 완료하기 위해 이미 다른 사용자를 생성한 경우가 많습니다. mysql 사용자를 생성하지 않은 경우 mysql/bin 디렉터리에 있는 mysqld_safe 파일을 수정하세요. //개인 테스트 성공
구체적인 단계:
[root@Master bin]# vim mysqld_safe user='mysql' 修改为 user='hadoop' //自己的用户 后边步骤基本相同* [root@Slave1 data]# service mysql start Starting MySQL...... ERROR! The server quit without updating PID file (/home/hadoop/ruanJian/mysql/data/Slave1.Hadoop.pid). [root@Master data]#vim Slave1.Hadoop.err //查看日志文件 160830 15:56:44 mysqld_safe Starting mysqld daemon with databases from /home/hadoop/ruanJian/mysql/data 2016-08-30 15:56:49 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2016-08-30 15:56:49 1990 [ERROR] Fatal error: Can't change to run as user 'mysql' ; Please check that the user exists! 2016-08-30 15:56:49 1990 [ERROR] Aborting 2016-08-30 15:56:49 1990 [Note] Binlog end 2016-08-30 15:56:49 1990 [Note] /home/hadoop/ruanJian/mysql/bin/mysqld: Shutdown complete 160830 15:56:49 mysqld_safe mysqld from pid file /home/hadoop/ruanJian/mysql/data/Slave1.Hadoop.pid ended
mysql 사용자 아래에 데이터 디렉터리를 생성하고 압축을 푼다
[root@Master data]# tar -zxvf mysql-5.6.12-linux-glibc2.5-x86_64.tar.gz [root@Master data]# mv mysql-5.6.12-linux-glibc2.5-x86_64 mysql //重命名
권한 설정
[root@Master data]# chown -R mysql:mysql mysql
사용자를 전환하고 mysql/scripts 디렉토리를 입력하세요
[root@Master data]# su mysql [mysql@Master data]$ cd mysql/scripts/ [mysql@Master scripts]$
설치(디렉터리는 자신의 mysql 압축 해제 디렉터리에 따라 설정됨)
[mysql@Master scripts]$ ./mysql_install_db --user=mysql --basedir=/home/mysql/data/mysql --datadir=/home/mysql/data/mysql/data
출력정보
Installing MySQL system tables...2016-08-30 19:55:41 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2016-08-30 19:55:42 1354 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000) 2016-08-30 19:55:42 1354 [Warning] Buffered warning: Changed limits: table_cache: 431 (requested 2000) 2016-08-30 19:55:42 1354 [Note] InnoDB: The InnoDB memory heap is disabled 2016-08-30 19:55:42 1354 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2016-08-30 19:55:42 1354 [Note] InnoDB: Compressed tables use zlib 1.2.3 2016-08-30 19:55:42 1354 [Note] InnoDB: Using Linux native AIO 2016-08-30 19:55:42 1354 [Note] InnoDB: Not using CPU crc32 instructions 2016-08-30 19:55:42 1354 [Note] InnoDB: Initializing buffer pool, size = 128.0M 2016-08-30 19:55:42 1354 [Note] InnoDB: Completed initialization of buffer pool 2016-08-30 19:55:42 1354 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created! 2016-08-30 19:55:42 1354 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB 2016-08-30 19:55:42 1354 [Note] InnoDB: Database physically writes the file full: wait... 2016-08-30 19:55:42 1354 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB 2016-08-30 19:55:43 1354 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB 2016-08-30 19:55:44 1354 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0 2016-08-30 19:55:44 1354 [Warning] InnoDB: New log files created, LSN=45781 2016-08-30 19:55:44 1354 [Note] InnoDB: Doublewrite buffer not found: creating new 2016-08-30 19:55:44 1354 [Note] InnoDB: Doublewrite buffer created 2016-08-30 19:55:44 1354 [Note] InnoDB: 128 rollback segment(s) are active. 2016-08-30 19:55:44 1354 [Warning] InnoDB: Creating foreign key constraint system tables. 2016-08-30 19:55:44 1354 [Note] InnoDB: Foreign key constraint system tables created 2016-08-30 19:55:44 1354 [Note] InnoDB: Creating tablespace and datafile system tables. 2016-08-30 19:55:44 1354 [Note] InnoDB: Tablespace and datafile system tables created. 2016-08-30 19:55:44 1354 [Note] InnoDB: Waiting for purge to start 2016-08-30 19:55:44 1354 [Note] InnoDB: 5.6.12 started; log sequence number 0 2016-08-30 19:55:44 1354 [Note] Binlog end 2016-08-30 19:55:44 1354 [Note] InnoDB: FTS optimize thread exiting. 2016-08-30 19:55:44 1354 [Note] InnoDB: Starting shutdown... 2016-08-30 19:55:46 1354 [Note] InnoDB: Shutdown completed; log sequence number 1625977 OK Filling help tables...2016-08-30 19:55:46 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2016-08-30 19:55:46 1377 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000) 2016-08-30 19:55:46 1377 [Warning] Buffered warning: Changed limits: table_cache: 431 (requested 2000) 2016-08-30 19:55:46 1377 [Note] InnoDB: The InnoDB memory heap is disabled 2016-08-30 19:55:46 1377 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2016-08-30 19:55:46 1377 [Note] InnoDB: Compressed tables use zlib 1.2.3 2016-08-30 19:55:46 1377 [Note] InnoDB: Using Linux native AIO 2016-08-30 19:55:46 1377 [Note] InnoDB: Not using CPU crc32 instructions 2016-08-30 19:55:46 1377 [Note] InnoDB: Initializing buffer pool, size = 128.0M 2016-08-30 19:55:46 1377 [Note] InnoDB: Completed initialization of buffer pool 2016-08-30 19:55:46 1377 [Note] InnoDB: Highest supported file format is Barracuda. 2016-08-30 19:55:46 1377 [Note] InnoDB: 128 rollback segment(s) are active. 2016-08-30 19:55:46 1377 [Note] InnoDB: Waiting for purge to start 2016-08-30 19:55:46 1377 [Note] InnoDB: 5.6.12 started; log sequence number 1625977 2016-08-30 19:55:46 1377 [Note] Binlog end 2016-08-30 19:55:46 1377 [Note] InnoDB: FTS optimize thread exiting. 2016-08-30 19:55:46 1377 [Note] InnoDB: Starting shutdown... 2016-08-30 19:55:48 1377 [Note] InnoDB: Shutdown completed; log sequence number 1625987 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: /home/mysql/data/mysql/bin/mysqladmin -u root password 'new-password' /home/mysql/data/mysql/bin/mysqladmin -u root -h Master.Hadoop password 'new-password' Alternatively you can run: /home/mysql/data/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 . ; /home/mysql/data/mysql/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd mysql-test ; perl mysql-test-run.pl Please report any problems with the ./bin/mysqlbug script! The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at http://shop.mysql.com New default config file was created as /home/mysql/data/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
구성 파일
[mysql@Master scripts]$ cd ../support-files/ [root@Master support-files]# cp my-default.cnf /etc/my.cnf [root@Master support-files]# cp mysql.server /etc/init.d/mysql [root@Master support-files]# vim /etc/init.d/mysql //修改mysql文件
다음 두 줄을 추가하세요
basedir=/home/mysql/data/mysql datadir=/home/mysql/data/mysql/data
환경 변수 구성
[root@Master support-files]# vim /etc/profile #set mysql environment export MYSQL_HOME=/home/mysql/data/mysql export PATH=$MYSQL_HOME/bin:$PATH
부팅 시 자동으로 시작되도록 mysql 서비스 구성
[root@Master bin]# chkconfig --add mysql //添加mysql [root@Master bin]# chkconfig mysql on //设置开机启动
mysql 시작
[root@Master support-files]# service mysql start env: /etc/init.d/mysql: 权限不够 //如果出现这个提示 执行以下命令重新启动 [root@Master support-files]# chmod a+wrx /etc/init.d/mysql [root@Master support-files]# service mysql start Starting MySQL.. SUCCESS! //启动成功
루트 로그인 비밀번호 설정
[root@Master ~]# cd /home/mysql/data/mysql/bin/ //进去mysql的bin目录 [root@Master bin]# ./mysqladmin -u root password 'password' //'password' 为自己设置的密码引号非必须 [root@Master bin]# ./mysqladmin -u root password mysql [root@Master bin]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.6.12 MySQL Community Server (GPL) Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
이상은 Linux에서 mysql-5.6.12-linux-glibc2.5-x86_64.tar.gz를 설치하는 방법에 대한 편집자의 소개입니다. 궁금한 사항이 있으면 남겨주세요. 메시지를 보내면 편집자가 제 시간에 모든 사람에게 답변을 드릴 것입니다. 홈페이지에 대한 귀하의 지원에 진심으로 감사드립니다!