mysql

作者: 小小爱笑 | 来源:发表于2019-01-26 16:55 被阅读0次

下载二进制包

https://dev.mysql.com/downloads/mysql/

解压

tar xvJf mysql-8.0.14-linux-glibc2.12-x86_64.tar.xz

建立软连接到/user/local

sudo ln -s /mnt/software/mysql-8.0.14-linux-glibc2.12-x86_64 /usr/local/mysql

shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
shell> cd /usr/local
shell> tar xvf /path/to/mysql-VERSION-OS.tar.xz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> mkdir mysql-files
shell> chown mysql:mysql mysql-files
shell> chmod 750 mysql-files

安装依赖so
sudo apt-get install numactl

shell> bin/mysqld --initialize --user=mysql

生成临时密码
A temporary password is generated for root@localhost: 9o5TO0gyob?,

shell> bin/mysql_ssl_rsa_setup
shell> bin/mysqld_safe --user=mysql &

Next command is optional

shell> cp support-files/mysql.server /etc/init.d/mysql.server

登陆mysql

mysql -uroot -p生成密码

修改默认密码:

ALTER USER 'root'@'localhost' IDENTIFIED BY '123'; flush privileges;

创建用户

创建可在非本地域访问的用户
CREATE USER 'gen'@'%' IDENTIFIED BY '123';
GRANT ALL PRIVILEGES ON . TO 'gen'@'%' WITH GRANT OPTION;


常见错误

连接失败

[root /opt/mysql/bin]$ ./mysql -udbuser -pAdmin@123 -h10.250.95.249
Warning: Using a password on the command line interface can be insecure.
ERROR 2003 (HY000): Can't connect to MySQL server on '10.250.95.249' (111)

原因: 端口不是默认端口3306时,需要显示设置端口。
./mysql -udbuser -pAdmin@123 -h10.250.95.249 -P32081


分页后 join

select * from (
select * from tbl_rfs_fc limit 3, 5) tt
left join tbl_rfs_node_relation t1 on tt.oid=t1.oid;

多表删除

delete t1,t2,t3,t4,t5,t6 from (
select cast(#{serviceOid,jdbcType=VARCHAR} AS varchar(128)) as cfs_oid
) t0 left join tbl_rfs_service_relation t1 on t0.cfs_oid=t1.client_oid
left join tbl_rfs_node_relation t2 on t0.cfs_oid=t2.service_oid or t1.service_oid=t2.service_oid
LEFT JOIN tbl_rfs_fc t3 on t2.oid=t3.oid or t2.service_oid=t3.oid
left join tbl_rfs_fcentity t4 on t2.oid=t4.oid
left join tbl_rfs_fcroute t5 on t2.oid=t5.oid
LEFT JOIN tbl_ne_fc t6 on t2.oid=t6.oid or t2.service_oid=t6.oid


假设远程主机的IP为:10.0.0.1,用户名为root,密码为123。则键入以下命令:

mysql -h10.0.0.1 -uroot -p123

https://dev.mysql.com/doc/refman/8.0/en/installing.html

初始化mysql

启动mysql服务
sudo ./bin/mysqld_safe --user=mysql &

连接mysql
sudo ./bin/mysql -u root

创建可在非本地域访问的用户
CREATE USER 'gen'@'%' IDENTIFIED BY '123';
GRANT ALL PRIVILEGES ON . TO 'gen'@'%' WITH GRANT OPTION;

检查mysql.user表

在Ubuntu服务器下,MySQL默认是只允许本地登录,因此需要修改配置文件将地址绑定给注释掉:
/#bind-address = 127.0.0.1

https://blog.csdn.net/weixx3/article/details/80782479

https://blog.csdn.net/maxsky/article/details/51171474

事务各隔离级别加锁情况
https://www.imooc.com/article/17290

RR和RC复合语句加锁
http://www.cnblogs.com/drizzlewithwind/p/8577735.html

https://www.cnblogs.com/yuyue2014/p/4747018.html

相关文章

网友评论

      本文标题:mysql

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