在新装的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. Contest Setting 2018 ICPC Pacific Northwest Regional Contest dp

    题目:https://vj.69fa.cn/12703be72f729288b4cced17e2501850?v=1552995458 dp这个题目网上说是dp+离散化这个题目要对这些数字先处理然后进 ...

  2. 【HNOI2016】大数

    [HNOI2016]大数 题目链接 题目描述 小 B 有一个很大的数 $ S $,长度达到了 $ N $ 位:这个数可以看成是一个串,它可能有前导 $ 0 $,例如 00009312345 .小 B ...

  3. centos7下安装docker(15.2跨主机网络-overlay)

    为支持容器跨主机通信,Docker提供了overlay driver,使用户可以创建基于VxLAN的overlay网络.VxLAN可将二层数据封装到UDP进行传输,VxLAN提供与VLAN相同的以太网 ...

  4. 安全管理器SecurityManager

    一.文章的目的 这是一篇对Java安全管理器入门的文章,目的是简单了解什么是SecurityManager,对管理器进行简单配置,解决简单问题. 比如在阅读源码的时候,发现这样的代码,想了解是做什么的 ...

  5. 转://Oracle PL/SQL 优化与调整 -- Bulk 说明

    一. Bulk 概述 本来只想测试一下Bulk Collect 和update性能的,但发现Bulk 的东西还是很多的,在OTN上搜了一些,整理如下. 1.1 Bulk Binding 和 Bulk ...

  6. 电脑如何用HDMI连接电视

    因为现在的液晶电视基本上都有VGA接口,所以你可以很容易地用VGA线实现电脑连接电视上,但是该文有一个地方没有提到,那就是分辨率的问 题,现在的液晶电视的主流面板已经是全高清面板(1920X1080) ...

  7. Python:margin collapse

    margin collapse:边界 折叠/重叠/坍塌 此种现象只会垂直方向并且要满足一定条件时才会出现这种现象. https://tech.youzan.com/css-margin-collaps ...

  8. apache反向代理出现502调整

    1.问题描述:项目上线后,会在接口调用时客户端出现502异常,而服务端则对该此请求作出处理. 2.问题原因:经过排查后得知是由于请求并发量大,造成超过请求超时间,但是apache中队列已经加载到请求信 ...

  9. 初学Python——进程

    什么是进程? 程序不能单独执行,只有将程序装载到内存中,系统为它分配资源才能运行,而这种执行的过程就叫做进程.进程是操作系统调度的最小单位. 程序和进程的区别在于:程序是储存在硬盘上指令的有序集合,是 ...

  10. python 全栈开发,Day42(Thread类的其他方法,同步锁,死锁与递归锁,信号量,事件,条件,定时器,队列,Python标准模块--concurrent.futures)

    昨日内容回顾 线程什么是线程?线程是cpu调度的最小单位进程是资源分配的最小单位 进程和线程是什么关系? 线程是在进程中的 一个执行单位 多进程 本质上开启的这个进程里就有一个线程 多线程 单纯的在当 ...