4.20+Linux+Mysql服务器搭建
来源:互联网 发布:head first python下载 编辑:程序博客网 时间:2024/06/12 01:07
MySQL服务器搭建
- VMware安装
- Xshell安装
- Mysql安装
- Java中连接MySql
- C语言中连接MySql
-直接从MySql设置开始
-成功安装之后
t1-cs-sicnu@cs-sicnu:~$ whereis mysqlmysql: /usr/bin/mysql /usr/lib/mysql /etc/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gzt1-cs-sicnu@cs-sicnu:~$
-查看Mysql进程
t1-cs-sicnu@cs-sicnu:~$ ps -aux | grep mysqlmysql 891 0.0 0.1 4476 1692 ? Ss 09:31 0:00 /bin/sh /usr/bin/mysqld_safemysql 1256 0.7 13.3 795492 133404 ? Sl 09:31 0:02 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock --port=3306t1-cs-s+ 2026 0.0 0.2 13712 2144 pts/8 S+ 09:36 0:00 grep --color=auto mysqlt1-cs-sicnu@cs-sicnu:~$
-查看运行端口
root@cs-sicnu:/home/t1-cs-sicnu# netstat -tpan | grep mysqltcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 1256/mysqld
-启动Mysql
root@cs-sicnu:/home/t1-cs-sicnu# mysql -uroot -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.6.31-0ubuntu0.15.10.1 (Ubuntu)
-查看ip
root@cs-sicnu:/home/t1-cs-sicnu# ifconfigeno16777736 Link encap:以太网 硬件地址 00:0c:29:b1:55:49 inet 地址:192.168.43.128 广播:192.168.43.255 掩码:255.255.255.0 inet6 地址: fe80::20c:29ff:feb1:5549/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 跃点数:1 接收数据包:78453 错误:0 丢弃:0 过载:0 帧数:0 发送数据包:16289 错误:0 丢弃:0 过载:0 载波:0 碰撞:0 发送队列长度:1000 接收字节:105937442 (105.9 MB) 发送字节:1694129 (1.6 MB) 中断:19 基本地址:0x2000
-只对本地监听
root@cs-sicnu:~# netstat -anp | grep 3306tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 1256/mysqld
-修改mysql 的myconf文件;
root@cs-sicnu:~# mysql --help | grep 'Default options' -A 1Default options are read from the following files in the given order:/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf
root@cs-sicnu:~# find / -name my.cnf/etc/alternatives/my.cnf/etc/mysql/my.cnf/var/lib/dpkg/alternatives/my.cnf^Croot@cs-sicnu:~# mysql --help | grep my.cnf order of preference, my.cnf, $MYSQL_TCP_PORT,/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf root@cs-sicnu:~# vim /etc/my.cnf
-打开任何my.conf都么有发现bind-address;
于是cat my.cnf
root@cs-sicnu:/usr# cat /etc/mysql/my.cnf## The MySQL database server configuration file.## You can copy this to one of:# - "/etc/mysql/my.cnf" to set global options,# - "~/.my.cnf" to set user-specific options.# # One can use all long options that the program supports.# Run program with --help to get a list of available options and with# --print-defaults to see which it would actually understand and use.## For explanations see# http://dev.mysql.com/doc/mysql/en/server-system-variables.html## * IMPORTANT: Additional settings that can override those from this file!# The files must end with '.cnf', otherwise they'll be ignored.#!includedir /etc/mysql/conf.d/!includedir /etc/mysql/mysql.conf.d/
进入 mysql.conf.d
root@cs-sicnu:/etc/mysql/mysql.conf.d# cat mysqld.cnf
内容如下:
skip-external-locking## Instead of skip-networking the default is now to listen only on# localhost which is more compatible and is not less secure.bind-address = 127.0.0.1## * Fine Tuning
成功找到bind-address。前面加上# 注释掉。监听任何连接。
# localhost which is more compatible and is not less secure.#bind-address = 127.0.0.1
以下代码防坑
root@cs-sicnu:~# sudo restart mysqlrestart: 无法连接到 Upstart: Failed to connect to socket /com/ubuntu/upstart: 拒绝连接root@cs-sicnu:~# service restart mysqlrestart: unrecognized serviceroot@cs-sicnu:~# service restart mysqldrestart: unrecognized serviceroot@cs-sicnu:~# restart mysqldrestart: 无法连接到 Upstart: Failed to connect to socket /com/ubuntu/upstart: 拒绝连接root@cs-sicnu:~# service mysql restartroot@cs-sicnu:~#
进入到Mysql
mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || cstest || cstestt1 || mysql || performance_schema |+--------------------+5 rows in set (0.06 sec)mysql>
对数据库任何主机访问权限,赋予权限;
mysql> grant all privileges on *.* TO 'root'@'%'identified by '1314' with grant option;Query OK, 0 rows affected (0.00 sec)
修改生效;
mysql> FLUSH PRIVILEGES;Query OK, 0 rows affected (0.00 sec)
退出mysql;
mysql> exit;Byeroot@cs-sicnu:~#
使用另一个Linux登陆;
root@t2-cs-sicnu:/home/t2-cs-sicnu# whereis mysqlmysql: /usr/bin/mysql /etc/mysql /usr/lib/mysql /usr/bin/X11/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gzroot@t2-cs-sicnu:/home/t2-cs-sicnu# mysql -uroot -p -h 192.168.43.128 -P3306Enter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 4Server version: 5.6.31-0ubuntu0.15.10.1 (Ubuntu)Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>
查看表格;
mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || cstest || cstestt1 || mysql || performance_schema |+--------------------+5 rows in set (0.01 sec)mysql>
成功!!!!!!
0 0
- 4.20+Linux+Mysql服务器搭建
- linux下搭建mysql服务器
- Linux 搭建数据库服务器(mysql)
- Linux环境Tomcat-MySQL的服务器搭建
- 搭建Linux服务器(MySQL,Tomcat,JDK)
- Linux服务器搭建之<MySQL>(二)
- Linux 搭建tomcat - MySql服务器(简易)
- 同一台linux服务器搭建两个mysql
- Linux搭建Java服务器环境-Mysql安装
- linux-搭建web服务器系列--搭建mysql数据库(二)
- 4.20+Linux+Git服务器搭建
- Mysql主从服务器搭建
- 快捷搭建mysql服务器
- Mysql服务器搭建
- 搭建mysql主从服务器
- 服务器搭建--MySql安装
- mysql 主从服务器搭建
- mysql主从服务器搭建
- jQuery DOM 元素方法
- 浅谈jQuery的$原理
- selenium+python 向富文本输入内容
- 资源|28本必读的经典机器学习/数据挖掘书籍(免费下载)
- HDU1284 钱币兑换问题
- 4.20+Linux+Mysql服务器搭建
- 优化 SQL 查询:如何写出高性能SQL语句
- Android性能优化-内存泄漏(上)
- windows环境Caffe安装配置步骤(无GPU)及mnist训练
- 【IMWeb训练营作业】 vue练习-todoList
- mysql条件添加
- 子页提交url后关闭子页刷新父级页面
- Java 正则表达式
- QPS 与 TPS 简介