当前位置:我的异常网» Linux/Unix » 装配mysql-5.6.37-linux-glibc2.12-x86_64.tar
装配mysql-5.6.37-linux-glibc2.12-x86_64.tar
www.myexceptions.net 网友分享于:2013-09-12 浏览:0次
安装mysql-5.6.37-linux-glibc2.12-x86_64.tar
参考 http://blog.csdn.net/u011391839/article/details/40110875
[root@localhost mysql]# cd /data/
[root@localhost mysql]# tar -zxvf mysql-5.6.37-linux-glibc2.12-x86_64.tar.gz
[root@localhost mysql]# mv mysql-5.6.37-linux-glibc2.12-x86_64/ mysql
查看用户和组
cat /etc/passwd查看所有的用户信息
cat /etc/passwd|grep 用户名
cat /etc/group查看所有组信息
cat /etc/group|grep 组名
[root@localhost mysql]# groupadd mysql
[root@localhost mysql]# useradd -r -g mysql mysql
[root@localhost mysql]# cd mysql/
[root@localhost mysql]# chown -R mysql:mysql ./
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql
Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
[root@localhost mysql]# yum -y install libaio*
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql
Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
原因:是用yum 安装的libnuma.so.1,但安装时默认安装的是32的,但db2需要的是64位的
解决办法:1.如果已经安装了libnuma.so.1,先yum remove libnuma.so.1;安装 yum -y install numactl.x86_64
[root@localhost mysql]# yum -y install numactl.x86_64
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql
修改当前目录拥有者为root用户:执行命令 chown -R root:root ./
修改当前data目录拥有者为mysql用户:执行命令 chown -R mysql:mysql data
到此数据库安装完毕
6. 启动mysql服务和添加开机启动mysql服务:
添加开机启动:执行命令cp support-files/mysql.server /etc/init.d/mysqld,把启动脚本放到开机初始化目录
cp /usr/local/mysql5/share/mysql/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 2345 mysqld on
[root@localhost mysql]# service mysqld start
Starting MySQL SUCCESS!
[root@localhost mysql]# ps -ef|grep mysql
root 4288 1 0 18:26 pts/1 00:00:00 /bin/sh /data/mysql/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/localhost.localdomain.pid
mysql 4464 4288 91 18:26 pts/1 00:00:11 /data/mysql/bin/mysqld --basedir=/data/mysql --datadir=/var/lib/mysql --plugin-dir=/data/mysql/lib/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/lib/mysql/localhost.localdomain.pid --socket=/var/lib/mysql/mysql.sock
root 4488 4215 0 18:27 pts/1 00:00:00 grep mysql
[root@localhost mysql]#
修改mysql的root用户密码,root初始密码为空的:
执行命令:./bin/mysqladmin -u root password '密码'
[root@localhost bin]# ./mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 5.6.37 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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> select * from user;
ERROR 1046 (3D000): No database selected
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.01 sec)
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| event |
| func |
| general_log |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| innodb_index_stats |
| innodb_table_stats |
| ndb_binlog_index |
| plugin |
| proc |
| procs_priv |
| proxies_priv |
| servers |
| slave_master_info |
| slave_relay_log_info |
| slave_worker_info |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
28 rows in set (0.00 sec)
mysql>
mysql> show variables ;
mysql> show global variables like 'hostname';
+---------------+-----------------------+
| Variable_name | Value |
+---------------+-----------------------+
| hostname | localhost.localdomain |
+---------------+-----------------------+
1 row in set (0.00 sec)
mysql> show global variables like 'port';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port | 3306 |
+---------------+-------+
1 row in set (0.01 sec)
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.6.37 |
+-----------+
1 row in set (0.01 sec)
mysql> status;
--------------
./mysql Ver 14.14 Distrib 5.6.37, for linux-glibc2.12 (x86_64) using EditLine wrapper
Connection id:4
Current database:mysql
Current user:root@localhost
SSL:Not in use
Current pager:stdout
Using outfile:''
Using delimiter:;
Server version:5.6.37 MySQL Community Server (GPL)
Protocol version:10
Connection:Localhost via UNIX socket
Server characterset:latin1
Db characterset:latin1
Client characterset:utf8
Conn. characterset:utf8
UNIX socket:/tmp/mysql.sock
Uptime:8 min 47 sec
Threads: 1 Questions: 57 Slow queries: 0 Opens: 87 Flush tables: 1 Open tables: 80 Queries per second avg: 0.108
--------------
mysql>
客户端连接报错:
解决 1130 - Host '192.168.162.16' is not allowed to connect to this MySQL server 方法:
1。 改表法。可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"
mysql -u root -pvmwaremysql>use mysql;mysql>update user set host = '%' where user = 'root';mysql>select host, user from user;
2. 授权法。例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
如果你想允许用户myuser从ip为192.168.1.3的主机连接到mysql服务器,并使用mypassword作为密码
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY
'mypassword' WITH GRANT OPTION;
mysql> update user set host = '%' where user = 'root';
ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
mysql> select host, user,Password from user;
+-----------------------+------+-------------------------------------------+
| host | user | Password |
+-----------------------+------+-------------------------------------------+
| % | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| localhost.localdomain | root | |
| 127.0.0.1 | root | |
| ::1 | root | |
| localhost | | |
| localhost.localdomain | | |
+-----------------------+------+-------------------------------------------+
6 rows in set (0.00 sec)
mysql> delete from user where host='localhost.localdomain' ;
Query OK, 2 rows affected (0.00 sec)
mysql> delete from user where host='127.0.0.1' ;
Query OK, 1 row affected (0.00 sec)
mysql> delete from user where host='localhost';
Query OK, 1 row affected (0.00 sec)
mysql> select host, user from user;
+------+------+
| host | user |
+------+------+
| % | root |
| ::1 | root |
+------+------+
2 rows in set (0.00 sec)
mysql> delete from user where host='::1';
Query OK, 1 row affected (0.00 sec)
重启数据库
[root@localhost ~]# service mysqld restart
Shutting down MySQL.... SUCCESS!
Starting MySQL.. SUCCESS!
[root@localhost ~]#
连接成功!!!
文章评论