在linux上安装MySQL数据库,并简单设置用户密码,登录MySQL
在新装的Centos系统上安装MySQL数据库。
<p><a href="http://www.cnblogs.com/tijun/">提君博客原创</a></p>
>>提君博客原创 http://www.cnblogs.com/tijun/ <<
第一步,检查是否已安装MySQL,如果已安装就卸载掉。
[root@ltt5 ~]# rpm -e mysql
error: package mysql is not installed
一步搞定,不需要事先执行检查命令了,直接执行卸载命令,有就删,没有也就不用管了。
第二步,执行安装
[root@ltt5 ~]# yum -y install mysql mysql-server mysql-devel
...
...
...
Complete!
出现complete表示安装成功。
查看版本
[hadoop@ltt5 ~]$ mysql -V
mysql Ver 14.14 Distrib 5.1., for redhat-linux-gnu (x86_64) using readline 5.1
>>提君博客原创 http://www.cnblogs.com/tijun/ <<
第三步,开启服务
[root@ltt5 ~]# service mysqld start
第四步,设置开机启动
[root@ltt5 ~]# chkconfig mysqld on
[root@ltt5 ~]# chkconfig --list mysqld
mysqld :off :off :on :on :on :on :off
第五步,修改数据库编码格式为 utf-8
[root@ltt5 ~]# vi /etc/my.cnf

在箭头位置添加如下内容
default-character-set=utf8
[client]
default-character-set=utf8
效果如下

重启服务
service mysqld restart
第六步,登录MySQL数据库
[root@ltt5 ~]# mysql -uroot
敲enter登录
第七步,设置远程登录
mysql> grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
Query OK, rows affected (0.00 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> select host,user,password from user;
+-----------+------+-------------------------------------------+
| host | user | password |
+-----------+------+-------------------------------------------+
| localhost | root | |
| yq | root | |
| 127.0.0.1 | root | |
| localhost | | |
| yq | | |
| % | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+-----------+------+-------------------------------------------+
rows in set (0.00 sec)
查看数据库编码格式
mysql> show variables like 'character_set_%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
rows in set (0.00 sec)
第八步,查看帮助
mysql> help; For information about MySQL products and services, visit:
http://www.mysql.com/
For developer information, including the MySQL Reference Manual, visit:
http://dev.mysql.com/
To buy MySQL Enterprise support, training, or other products, visit:
https://shop.mysql.com/ List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
? (\?) Synonym for `help'.
clear (\c) Clear the current input statement.
connect (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter.
edit (\e) Edit command with $EDITOR.
ego (\G) Send command to mysql server, display result vertically.
exit (\q) Exit mysql. Same as quit.
go (\g) Send command to mysql server.
help (\h) Display this help.
nopager (\n) Disable pager, print to stdout.
notee (\t) Don't write into outfile.
pager (\P) Set PAGER [to_pager]. Print the query results via PAGER.
print (\p) Print current command.
prompt (\R) Change your mysql prompt.
quit (\q) Quit mysql.
rehash (\#) Rebuild completion hash.
source (\.) Execute an SQL script file. Takes a file name as an argument.
status (\s) Get status information from the server.
system (\!) Execute a system shell command.
tee (\T) Set outfile [to_outfile]. Append everything into given outfile.
use (\u) Use another database. Takes database name as argument.
charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
warnings (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement. For server side help, type 'help contents'
第九步,查看系统原装的数据库
mysql> show databases
-> ;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
rows in set (0.00 sec)
第十步,创建数据库
<p><a href="http://www.cnblogs.com/tijun/">提君博客原创</a></p>
mysql> create database hive
-> ;
Query OK, row affected (0.00 sec) mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| hive |
| mysql |
| test |
+--------------------+
rows in set (0.00 sec)
第十一步,退出
mysql> quit
Bye
至此,MySQL数据的安装和简单设置就介绍完毕。
>>提君博客原创 http://www.cnblogs.com/tijun/ <<
<p><a href="http://www.cnblogs.com/tijun/">提君博客原创</a></p>
在linux上安装MySQL数据库,并简单设置用户密码,登录MySQL的更多相关文章
- 在linux上安装elasticsearch简称ES 简单介绍安装步骤
1.简介 Elasticsearch 是一个分布式可扩展的实时搜索和分析引擎,一个建立在全文搜索引擎 Apache Lucene(TM) 基础上的搜索引擎.当然 Elasticsearch 并不仅仅是 ...
- MySQL数据库(13)----忘记root用户密码解决方案【转载】
1.首先确认服务器出于安全的状态,也就是没有人能够任意地连接MySQL数据库. 因为在重新设置MySQL的root密码的期间,MySQL数据库完全出于没有密码保护的 状态下,其他的用户也可以任意地登录 ...
- 在 Linux 上安装 Oracle 数据库 11g
http://www.oracle.com/ocom/groups/public/@otn/documents/webcontent/229016_zhs.htm
- 在linux上安装postgresql数据库
#postgres useradd postgres chown -R postgres:postgres /media su postgres mkdir -p /media/Data1/postg ...
- 在Linux系统上安装Oracle数据库
前期准备:我用的是虚拟机上的CentOS 64位系统.所以需要设置网卡,时间,EPEL源,安装一些必备的软件. 1.1在虚拟机上安装好Linux系统后选择虚拟机设置—>网络适配器—>网络连 ...
- Linux上安装java+tomcat+mysql运行环境
centos6.5jdk"1.7.0_79"mysql5.6apache-tomcat-7.0.53 安装jdk:1.先到oracle下载rpm包:jdk-7u80-linux-x ...
- Linux上安装和卸载mysql数据库 (一)
一.前言 第一次写博客,很激动同时有点畏惧,激动是我可以将我的经验进行分享,畏惧是我怕我写的东西,大家借鉴的时候,有些步骤不能成功.不过,我还是很有信息的,我分享的经验都是我搭建成功以后才分享出来.这 ...
- 怎样在 Ubuntu Linux 上安装 MySQL
本教程教你如何在基于 Ubuntu 的 Linux 发行版上安装 MySQL.对于首次使用的用户,你将会学习到如何验证你的安装和第一次怎样去连接 MySQL. -- Sergiu MySQL 是一个典 ...
- linux操作mysql数据库常用简单步骤
连接mysql数据库: 主要看mysql安装在哪一个目录下: mysql -h主机地址 -u用户名 -p用户密码 或者mysql -h ip地址 -u zaiai -p zaiai 或者/v ...
随机推荐
- C#编程の泛型编程
什么是泛型 我们在编写程序时,经常遇到两个模块的功能非常相似,只是一个是处理int数据,另一个是处理string数据,或者其他自定义的数据类型,但我们没有办法,只能分别写多个方法处理每个数据类型,因为 ...
- dicom学习文章
https://blog.csdn.net/column/details/dicom.html https://blog.csdn.net/zssureqh/article/details/49231 ...
- java.util.concurrent包学习笔记(一)Executor框架
类图: 其实从类图我们能发现concurrent包(除去java.util.concurrent.atomic 和 java.util.concurrent.locks)中的内容并没有特别多,大概分为 ...
- docker swarm:Error response from daemon: rpc error: code = Unavailable desc = grpc: the connection is unavailable
环境:cetos7 描述:创建完docker swarm,想把node主机加入swarm中,执行以下命令时,报错 无法连接! 原因是:防火墙!!!!!!!没关!!!! 解决办法是:关闭防火墙
- [TJOI2017]城市
嘟嘟嘟 这题刚开始想复杂了,想什么dp去了,其实没那么难. 考虑断掉一条边,记分离出来的两棵子树为A和B,那么合并后的树的直径可能有三种情况: 1.A的直径. 2.B的直径 3.A的半径+边权+B的半 ...
- ansible批量免秘登录
ansible批量免秘登录 主控机 10.22.0.185 centos7 被控机 10.22.0.186 centos7 一.主控机安装ansible yum install epel-rele ...
- Spring配置中的"classpath:"与"classpath*:"的区别研究(转)
Spring配置中的"classpath:"与"classpath*:"的区别研究(转) 概念解释及使用场景: classpath是指WEB-INF文件夹下 ...
- Edusoho之LAMP环境搭建
主要参考官方文档Ubuntu16.04+Apache+PHP+MySQL+EduSoho 安装教程LAMP环境按照如下搭建是没有问题的,本地虚拟机试验是完全没有问题的. 1.更新 sudo apt-g ...
- JAVA 垃圾收集算法,垃圾收集器与内存分配策略(内容全面,解析简单易懂)
垃圾收集器需要解决的三个问题: 1)哪些内存需要回收 2)什么时候回收 3)如何回收 背景:程序计数器,虚拟机栈,本地方法栈3个区域随线程而生,随线程而灭,在这几个区域内不需要过多的考虑回收的问题,因 ...
- 【转】WPF PasswordBox不支持绑定解决方法
原文地址:https://www.cnblogs.com/wxjing67/p/3935717.html PasswordBox的Password属性因为安全原因不支持直接绑定,可以使用依赖属性实现. ...