- 浏览: 301730 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (298)
- Tomcat (3)
- ZooKeeper (1)
- Maven (11)
- opensource (1)
- DataBase (5)
- UML (8)
- linux (87)
- Java (32)
- 算法 (3)
- Redis (1)
- HBase (2)
- 产品 (1)
- 模板引擎 (1)
- Eclipse (10)
- JUnit (5)
- Log4j (8)
- XML (2)
- JSON (1)
- SpringMVC (23)
- Spring (24)
- TCP/IP (4)
- Windows (10)
- Web Service (1)
- 源码版本管理 (1)
- Word (1)
- Test (1)
- Mybatis (7)
- CentOS (2)
- 多线程 (2)
- Web (7)
- Servlet (3)
- JavaWeb (4)
- MySQL (7)
- 汇编语言 (2)
- linux Shell (4)
- GIT (4)
- Python (1)
- 并发 (4)
- 编程通用 (1)
- JavaScript (1)
- 异常 (3)
- 自动化部署 (1)
- 大数据 (1)
- hive (2)
- 文本编辑器 (2)
- MINA (0)
- intellij IDEA (9)
- masm (0)
- blockchain (1)
- docker (2)
- IDEA (0)
- GO (3)
- nginx (1)
- springBoot (3)
- Websocket (2)
- macOS (1)
最新评论
-
woodding2008:
ss –pl 可以查看监听方式启动的端口以及pid
根据端口查PID,根据PID查进程名称 -
masuweng:
恩很试用,也很常用。
linux 常用命令
参考 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 ~]#
连接成功!!!
[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 ~]#
连接成功!!!
发表评论
-
mysql update select 从查询结果中更新数据
2018-09-12 10:37 1870实际案例: UPDATE chat_messages as ... -
com.alibaba.druid.pool.DruidDataSource[612] - init datasource error
2017-09-24 15:35 27572017-09-24 11:38:35,294 ERROR - ... -
linux系统下安装64位mysql 5.6的过程
2017-08-25 19:04 1288引用: http://blog.csdn.net/u0113 ... -
Please read "Security" section of the manual to find out how to run mysqld a
2017-01-09 21:16 12251 启动: [root@localhost bin]# my ... -
CentOS使用yum安装mariaDB(开源MySQL)
2016-11-16 11:36 5811 查看CentOS的mariadb是否已安装 [root@l ... -
mysql设置成网络数据库,即远程访问mysql,修改root密码
2016-11-16 11:36 5691MySQL修改密码 update mysql.user ...
相关推荐
mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz 卷1 共两卷,这是卷1,要把卷1和卷2都下载到同一目录才能解压 卷2下载地址: https://download.csdn.net/download/tan3739/11528995 MySQL For Linux 64位(兼容32位) ...
mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz.zip.001 卷1 mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz.zip.002 卷2 需要把 卷1与卷2都下载到同一目录后,才可以解压 卷1下载地址: ... 解压后文件为: mysql-5.7.25-...
MySQL Cluster 8.0.27( Linux - ...mysql-cluster-8.0.27-linux-glibc2.12-x86_64.part2.rar https://download.csdn.net/download/weixin_43800734/43757676 mysql-cluster-8.0.27-linux-glibc2.12-x86_64.part1.rar ...
mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz 卷2 共两卷,这是卷2,要把卷1和卷2都下载到同一目录才能解压 卷1下载地下: https://download.csdn.net/download/tan3739/11529259 MySQL For Linux 64位(兼容32位) ...
1、在官网上下载mysql-5.7.22-linux,我下载的是mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz,https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz,centos7/64位。...
本压缩包文件“mysql-5.7.29-linux-glibc2.12-x86_64.tar.zip”包含了在Linux环境下运行的MySQL服务器的二进制文件,特别适配于使用glibc2.12库的x86_64架构系统。 1. MySQL 5.7.29 版本概述: MySQL 5.7系列是...
这个特定的压缩包"mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz.7z"包含了MySQL 5.7.30版本,这是MySQL的稳定版本,适用于Linux操作系统,特别是那些使用glibc 2.12库的系统。glibc(GNU C Library)是Linux上的主要...
mysql-5.7.37-linux-glibc2.12-x86_64.tar,Linux版mysql5.7版本的数据库安装包
本文将详述关于“mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz”这个压缩包所代表的知识点。 首先,"mysql-5.7.30"是MySQL的版本号,它表明这是5.7系列的一个具体版本。5.7版是MySQL的一个重要里程碑,因为它引入了...
mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
这个压缩包文件"mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz"包含了适用于Linux操作系统的MySQL 5.7.31稳定版的二进制安装包,特别为glibc 2.12库优化,适用于基于x86_64架构的系统。这里我们将深入探讨MySQL 5.7的...
最新版linux mysql-8.0.22-linux-glibc2.12-x86_64.tar.xz最新版linux mysql-8.0.22-linux-glibc2.12-x86_64.tar.xz
MySQL数据库Linux - Generic版本:mysql-8.0.26-linux-glibc2.12-x86_64.tar.xz 适用于:Linux - Generic (glibc 2.12) (x86, 64-bit), Compressed TAR Archive
最新版linux mysql-8.0.23-linux-glibc2.12-x86_64.tar.xz最新版linux mysql-8.0.23-linux-glibc2.12-x86_64.tar.xz
mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz 截至2018.05.09 最新版MySQL For Linux 64位(兼容32位) 大小:575.1M MD5: c1b7e64241866ed68f7c637c99fe39a4
mysql5.6安装包 mysql-5.6.45-linux-glibc2.12-x86_64.tar.gz
mysql-8.0.16-linux-glibc2.12-x86_64.tar.xz
mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz mysql5.6b版本,适合linux centos6 个centos7离线安装,tar.gz包
在Linux环境下,可以使用`tar -zxvf mysql-test-5.7.33-linux-glibc2.12-x86_64.tar.gz`命令来解压缩文件,然后按照官方文档的指导进行安装和配置。 6. **配置与启动**: 解压缩后,需要配置MySQL的设置,如数据...