美文网首页
MySQL的简单使用

MySQL的简单使用

作者: 凌乱_8b06 | 来源:发表于2022-01-22 23:55 被阅读0次

#vi /etc/sysconfig/network-scripts/ifcfg-eth0 修改ip

#service network restart  重启网卡

# yum install -y wget    安装wget

#yum clean all

#yum makecache

#cd /usr/local/src/  到/usr/local/src/

#wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.53-linux2.6-x86_64.tar.gz

                                                            下载mysql

#tar zxvf mysql-5.5.53-linux2.6-x86_64.tar.gz    解压 mysql文件

#useradd -s /sbin/nologin -M mysql    创建 mysql用户

# mv mysql-5.5.53-linux2.6-x86_64 /usr/local/mysql 把文件移动到/usr/local/mysql

                                                            这个文件是重新命名的

#cd /usr/local/mysql

# ls                                  显示其目录下的文件

bin      data  include        lib  mysql-test  scripts  sql-bench

COPYING  docs  INSTALL-BINARY  man  README      share    support-files

# mkdir -p /data/mysql/              创建一个目录

#chown -R mysql:mysql /data/mysql    修改权限,(且目录下文件的权限一起修改)

# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql  初始化,提示安装libaio

--------------------------------------------------------------------------------

Installing MySQL system tables...

./bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

Installation of system tables failed!  Examine the logs in

/data/mysql for more information.

You can try to start the mysqld daemon with:

    shell> ./bin/mysqld --skip-grant &

and use the command line tool ./bin/mysql

to connect to the mysql database and look at the grant tables:

    shell> ./bin/mysql -u root mysql

    mysql> show tables

Try 'mysqld --help' if you have problems with paths.  Using --log

gives you a log in /data/mysql that may be helpful.

Please consult the MySQL manual section

'Problems running mysql_install_db', and the manual section that

describes problems on your OS.  Another information source are the

MySQL email archives available at http://lists.mysql.com/.

Please check all of the above before submitting a bug report

at http://bugs.mysql.com/

--------------------------------------------------------------------------

#yum install -y libaio  安装 libaio

#./scripts/mysql_install_db --user=mysql --datadir=/data/mysql

初始化没有mysql

# echo $? 提示0 证明没有错误

0

[root@localhost mysql]# cp support-files/my-

my-huge.cnf            my-large.cnf            my-small.cnf

my-innodb-heavy-4G.cnf  my-medium.cnf

=================================================================================

[root@localhost mysql]# cp support-files/my-large.cnf  /etc/my.cnf 把my-large.cnf 拷贝到 /etc/my.cnf 下  mysql的配置文件   

cp: overwrite `/etc/my.cnf'? y                  (因为有了这文件)确定覆盖此文件

#cd /usr/local/mysql/  (我所安装的mysql的路径)

[root@localhost mysql]# ls  显示

bin      data  include        lib  mysql-test  scripts  sql-bench

COPYING  docs  INSTALL-BINARY  man  README      share    support-files

[root@localhost mysql]# cp support-files/mysql.server  /etc/init.d/mysqld    /etc/init.d/  目录下面 是需要开机启动的服务的启动文件

support-files/mysql.server【启动文件】  /etc/init.d/mysqld

(把mysql服务启动文件复制到/etc/init.d/mysqld)

mysql]# chmod 755 /etc/init.d/mysqld 给以mysqld文件

【root用户可以可读可写可执行 root用户组和其他用户可以查看文件内容,并执行这个文件】

# vi /etc/init.d/mysqld 编辑这个文件

basedir=/usr/local/mysql

datadir=/data/mysql

[root@localhost mysql]# chkconfig --add mysqld  把MySQL添加到系统服务中

[root@localhost mysql]# chkconfig mysqld on  关闭mysql

【[root@localhost mysql]# chkconfig mysqld start ?????】

可知是哪里错误了?

# ps aux |grep mysql    查看状态

root      2104  0.0  0.0 103244  860 pts/0    S+  22:52  0:00 grep mysql

#service mysqld start  启动MySQL  前者命令敲错了

Starting MySQL.... SUCCESS!

[root@localhost mysql]# ps aux |grep mysql

root      2132  0.0  0.1  11304  1500 pts/0    S    23:05  0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/localhost.localdomain.pid

mysql    2424  0.4  9.1 747416 93456 pts/0    Sl  23:05  0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/localhost.localdomain.err --pid-file=/data/mysql/localhost.localdomain.pid --socket=/tmp/mysql.sock --port=3306

root      2449  0.0  0.0 103244  864 pts/0    S+  23:06  0:00 grep mysql

在Windows 命令行下 telnet  192.168.11.136 3306

#netstat -tan 查看端口命令

Active Internet connections (servers and established)

Proto Recv-Q Send-Q Local Address              Foreign Address            State

tcp        0      0 0.0.0.0:22                  0.0.0.0:*                  LISTEN

tcp        0      0 127.0.0.1:25                0.0.0.0:*                  LISTEN

tcp        0      0 0.0.0.0:3306                0.0.0.0:*                  LISTEN

tcp        0    64 192.168.11.136:22          192.168.11.107:49910        ESTABLISHED

tcp        0      0 :::22                      :::*                        LISTEN

tcp        0      0 ::1:25                      :::*                        LISTEN

[root@localhost mysql]# service mysqld restart 重新启动MySQL

Shutting down MySQL. SUCCESS!

Starting MySQL.. SUCCESS!

[root@localhost mysql]# ss -tan 查看端口

State      Recv-Q Send-Q                    Local Address:Port                      Peer Address:Port

LISTEN      0      128                                  :::22                                  :::*

LISTEN      0      128                                    *:22  任何人都可以防火墙端口开着                                  *:*

LISTEN      0      100                                  ::1:25                                  :::*

LISTEN      0      100                            127.0.0.1:25                                    *:*

LISTEN      0      50                                    *:3306                                  *:*

ESTAB      0      64                        192.168.11.136:22                      192.168.11.107:49910

相关文章

  • MySQL View 视图分析

    为什么MySQL中很少使用视图功能? 首先MySQL使用视图有什么好处: 清晰简单,可以让简单的语句逻辑更清晰 可...

  • MySQL的简单使用

    内容转载自我自己的博客 MySQL介绍 MySQL为关系型数据库管理系统(Relational Database ...

  • MySQL的简单使用

    #vi /etc/sysconfig/network-scripts/ifcfg-eth0 修改ip #servi...

  • mysql:简单使用

    打开cmd,查看mysql版本,mysql -- version登录,mysqu -u root -p输入root...

  • MySql 简单使用

    登陆mysql 在cmd命令行中输入 然后输入密码 创建数据库 显示现在的数据库 删除数据库

  • mysql:简单使用

    打开cmd,查看mysql版本,mysql -- version登录,mysqu -u root -p输入root...

  • 简单使用MySQL

    安装 MySQL库 npm i -S mysql 配置 新建db目录,内含index.js 和 config.js...

  • MySQL | 如何简单使用 MySQL

    前置知识 | MySQL 项目中要用到 MySQL 学一下 第一步当然是下载安装啦QLhttps://www.my...

  • 解决MySQL中文乱码-Linux

    简单有效解决MySQL中文乱码的问题 1 查看MySQL的编码 使用 mysql -u root -p 登入mys...

  • [MySQL] mysql查看表结构以及创建表、库命令

    本人写的所有的文档都是使用的MySQL版本为5.7.2. 我们在使用mysql的使用有很多查看表结构的语句:最简单...

网友评论

      本文标题:MySQL的简单使用

      本文链接:https://www.haomeiwen.com/subject/ilophrtx.html