在新装的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的更多相关文章

  1. 在linux上安装elasticsearch简称ES 简单介绍安装步骤

    1.简介 Elasticsearch 是一个分布式可扩展的实时搜索和分析引擎,一个建立在全文搜索引擎 Apache Lucene(TM) 基础上的搜索引擎.当然 Elasticsearch 并不仅仅是 ...

  2. MySQL数据库(13)----忘记root用户密码解决方案【转载】

    1.首先确认服务器出于安全的状态,也就是没有人能够任意地连接MySQL数据库. 因为在重新设置MySQL的root密码的期间,MySQL数据库完全出于没有密码保护的 状态下,其他的用户也可以任意地登录 ...

  3. 在 Linux 上安装 Oracle 数据库 11g

    http://www.oracle.com/ocom/groups/public/@otn/documents/webcontent/229016_zhs.htm

  4. 在linux上安装postgresql数据库

    #postgres useradd postgres chown -R postgres:postgres /media su postgres mkdir -p /media/Data1/postg ...

  5. 在Linux系统上安装Oracle数据库

    前期准备:我用的是虚拟机上的CentOS 64位系统.所以需要设置网卡,时间,EPEL源,安装一些必备的软件. 1.1在虚拟机上安装好Linux系统后选择虚拟机设置—>网络适配器—>网络连 ...

  6. Linux上安装java+tomcat+mysql运行环境

    centos6.5jdk"1.7.0_79"mysql5.6apache-tomcat-7.0.53 安装jdk:1.先到oracle下载rpm包:jdk-7u80-linux-x ...

  7. Linux上安装和卸载mysql数据库 (一)

    一.前言 第一次写博客,很激动同时有点畏惧,激动是我可以将我的经验进行分享,畏惧是我怕我写的东西,大家借鉴的时候,有些步骤不能成功.不过,我还是很有信息的,我分享的经验都是我搭建成功以后才分享出来.这 ...

  8. 怎样在 Ubuntu Linux 上安装 MySQL

    本教程教你如何在基于 Ubuntu 的 Linux 发行版上安装 MySQL.对于首次使用的用户,你将会学习到如何验证你的安装和第一次怎样去连接 MySQL. -- Sergiu MySQL 是一个典 ...

  9. linux操作mysql数据库常用简单步骤

    连接mysql数据库: 主要看mysql安装在哪一个目录下: mysql -h主机地址 -u用户名 -p用户密码   或者mysql -h ip地址 -u  zaiai -p zaiai   或者/v ...

随机推荐

  1. node基础—模块系统

    模块的概念 为了让Node.js的文件可以相互调用,Node.js提供了一个简单的模块加载系统. 在 Node.js 中,文件和模块是一一对应的(每个文件被视为一个独立的模块),换言之,一个 Node ...

  2. 2293: Distribution Center 中南多校

    Description The factory of the Impractically Complicated Products Corporation has many manufacturing ...

  3. 最短路 summary

    有四种类型: 单源:dij,spfa,bellman-ford 多源:floyd dij有两种: 一个复杂度为n^2,一个复杂度是m*logn 畅通工程续 某省自从实行了很多年的畅通工程计划后,终于修 ...

  4. centos7下安装docker(17.3docker监控---cAdvisor)

    cAdvisor是google开发的容器监控工具 1.在host上运行cadvisor容器 docker run -d -p 8080:8080 --name cadvisor -v /:/rootf ...

  5. 003_python内置的@staticmethod详解

    python中的staticmethod 主要是方便将外部函数集成到类体中,美化代码结构,重点在不需要类实例化的情况下调用方法(类似java的静态方法) 如果你去掉staticmethod,在方法中加 ...

  6. Fastcgi工作原理

    FastCGI是一个可伸缩的,高速地在HTTP server和动态脚本语言间的接口 FastCGI优点 这种方式可以让HTTP服务器专一的处理静态请求或者将动态脚本服务器返回给客户端,很大程度上提高了 ...

  7. javascript之Map

    javascript中的map,我用的不是特别多,倒是Java中的Map或HashMap,经常用. 顺便围绕几个方面介绍一下map? 1.Map对象 Map对象是一种有对应键值对的对象,JS的Obje ...

  8. GFF高仿QQ客户端及服务器

    一.GFF简介 GFF是仿QQ界面,通信基于SAEA.MessageSocket.SAEA.Http.SAEA.MVC实现包含客户端和服务器的程序,源码完全公开,项目源码地址:https://gith ...

  9. Google 宣布在 4 月 1 日关闭站内搜索

    今春,Google 计划终止又一项产品,它就是“站内搜索”(Site Search)功能.这项产品主要出售给 web 出版商,让它们可以在自家网站内运用业内领先的搜索技术.虽然该公司并未公开宣布此事, ...

  10. Jmeter(三十六)_运行过程中改变负载

    顾名思义,jmeter在做性能测试时,可以在不停止脚本的情况下修改负载压力,达到期望的测试效果.我们将通过Constant Throughput Timer(吞吐量计时器)和Beanshell服务器来 ...