linux mysql误删,linux下MySQL安装与删除 (Ubuntu)

1、MySQL安装

A)MySQL安装: sudo apt-get install mysql-server mysql-client

B)启动/停止MySQL服务:

MySQL 在安装以后,MySQL 就已经启动;如果需要手动启动或停止则如下操作:

手动启动服务: sudo start mysql

手动停止服务: sudo stop mysql

当修改mysql相关配置的时候,需要手动重启MySQL服务,就需要如上操作。

查看mysql进程是否已经启动:

ps

-aux | grep mysql

#ps -aux 显示当前所有进程(包括 mysql , 和 name 用户 ), grep mysql 用来查找 mysql

进程 ;具体使用可以查看 ps, grep 用法

#man ps ; man grep

或者使用:

sudo

netstat -tap | grep mysql

两种命令的结果:

name@ThinkPad:~$ ps -aux | grep mysql

Warning: bad ps syntax, perhaps a bogus

'-'

mysql 25994

0.0 0.9 137800

18400 ?

Ssl 10:18 0:10 /usr/sbin/mysqld

name 26543

0.0 0.1 8544

2320 pts/2

S+ 11:06

0:00

mysql -u root -p

name 27068

0.0 0.1 8388

2064 pts/1

S+ 18:21

0:00

mysql -u root -p

name 27917

0.0 0.0 5412

788 pts/3

S+ 21:45

0:00

grep --color=auto mysql

name@ThinkPad:~$ sudo netstat -tap | grep

mysql

tcp 0

0 localhost:mysql *:* LISTEN 25994/mysqld

C)MySQL 配置文件结构:

MySQL 配置文件为 my.cnf , 位置在 /etc/my.cnf 以及 /etc/mysql/my.cnf

#

# The

MySQL database server configuration file.

#

# You

can copy this to one of:

#

- "/etc/mysql/my.cnf"

to set global options,

#

- "~/.my.cnf" to set user-specific options.

#

# One

can use all long options that the program supports.

# Run

program with --help

to get a list of available options and

with

#

--print-defaults to see which it would actually understand and

use.

#

#

For explanations see

#

This will be passed to all

mysql clients

#

It has been reported that passwords should be enclosed with

ticks/quotes

#

escpecially if they contain "#" chars...

#

Remember to edit /etc/mysql/debian.cnf when changing the socket

location.

[client]

port = 3306

socket = /var/run/mysqld/mysqld.sock

#

Here is entries for some specific programs

#

The following values assume you have at least 32M ram

#

This was formally known as [safe_mysqld]. Both versions are

currently parsed.

[mysqld_safe]

socket = /var/run/mysqld/mysqld.sock

nice = 0

[mysqld]

#

# *

Basic Settings

#

#

# *

IMPORTANT

#

If you make changes to these settings and your system uses

apparmor, you may

#

also need to also adjust

/etc/apparmor.d/usr.sbin.mysqld.

#

user = mysql

socket = /var/run/mysqld/mysqld.sock

port = 3306

basedir = /usr

datadir = /var/lib/mysql

tmpdir = /tmp

skip-external-locking

#

#

Instead of skip-networking the default is now to listen

only on

#

localhost which is more compatible and is not less

secure.

bind-address = 127.0.0.1

#

# *

Fine Tuning

#

key_buffer = 16M

max_allowed_packet = 16M

thread_stack = 192K

thread_cache_size = 8

#

This replaces the startup script and checks MyISAM tables if

needed

#

the first time they are touched

myisam-recover = BACKUP

#max_connections = 100

#table_cache = 64

#thread_concurrency = 10

#

# *

Query Cache Configuration

#

query_cache_limit = 1M

query_cache_size = 16M

#

# *

Logging and Replication

#

#

Both location gets rotated by the cronjob.

#

Be aware that this log type is a performance killer.

#

As of 5.1 you can enable the log at runtime!

#general_log_file =

/var/log/mysql/mysql.log

#general_log = 1

log_error = /var/log/mysql/error.log

#

Here you can see queries with especially long duration

#log_slow_queries =

/var/log/mysql/mysql-slow.log

#long_query_time = 2

#log-queries-not-using-indexes

#

#

The following can be used as easy to replay backup logs or for

replication.

#

note: if you are setting up a replication slave, see README.Debian

about

#

other settings you may need to change.

#server-id = 1

#log_bin = /var/log/mysql/mysql-bin.log

expire_logs_days = 10

max_binlog_size = 100M

#binlog_do_db = include_database_name

#binlog_ignore_db = include_database_name

#

# *

InnoDB

#

#

InnoDB is enabled by default

with a 10MB datafile in

/var/lib/mysql/.

#

Read the manual for more InnoDB related options. There are

many!

#

#

* Security Features

#

#

Read the manual, too, if you want chroot!

#

chroot = /var/lib/mysql/

#

#

For generating SSL certificates I recommend the OpenSSL GUI

"tinyca".

#

#

ssl-ca=/etc/mysql/cacert.pem

#

ssl-cert=/etc/mysql/server-cert.pem

#

ssl-key=/etc/mysql/server-key.pem

[mysqldump]

quick

quote-names

max_allowed_packet = 16M

[mysql]

#no-auto-rehash # faster start of mysql

but no tab completition

[isamchk]

key_buffer = 16M

#

#

* IMPORTANT: Additional settings that can override those from this

file!

#

The files must end with '.cnf', otherwise

they'll be ignored.

#

!includedir /etc/mysql/conf.d/

在启动MySQL的时候会通过读取配置文件my.cnf ,并根据这个文件的路径:

/var/run/mysqld/mysqld.sock 启动MySQL

datadir = /var/lib/mysql

#这句是数据库所在位置,比如如果创建一个数据库mysql_first,则数据库文件放置在该目录下。

log_error = /var/log/mysql/error.log #

mysql错误文件,如果在执行mysql出错了,可以查看该文件。

D)进入MySQL

进入MySQL一般需要密码, 除非使用 safe_mysql

如果不提供密码则会出现如下错误提示:

ERROR 1045

(28000): Access denied

for user 'name'@'localhost'

(using password: NO)

这是因为在安装MySQL输入了密码,需要提供密码;

具体:

name@ThinkPad:~$ sudo mysql -u root -p

Enter

password:

Welcome to the MySQL monitor. Commands end with ; or

\g.

Your

MySQL connection id is 40

Server version: 5.1.58-1ubuntu1

(Ubuntu)

Copyright (c) 2000,

2010, Oracle

and/or its affiliates. All rights reserved.

This

software comes with ABSOLUTELY NO WARRANTY. This is free

software,

and

you are welcome to modify and redistribute it under the GPL

v2 license

Type 'help;'

or '\h' for

help.

Type '\c' to clear the current input statement.

mysql>

sudo mysql -u root -p # 这里的几个参数: u 表示 user ,后面是参数; p 表示 password

,会在后面有 Enter password: 提示

也可以直接提供用户和密码(使用 -- )

sudo mysql --user=root --password=123456

C)退出MySQL

主要有三种方式:

mysql> exit

Bye

mysql> quit

Bye

mysql> #直接按Ctrl + D

2、卸载MySQL

A)卸载MySQL软件

sudo

apt-get autoremove --purge mysql-server-5.1

sudo

apt-get remove mysql-server

sudo

apt-get autoremove mysql-server

sudo

apt-get remove mysql-common

sudo apt-get autoremove --purge

mysql-server-5.1 # 中 mysql-server-5.1是系统安装的 mysql-server版本

B)清理其他数据

dpkg

-l |grep ^rc|awk '{print

$2}' |sudo xargs dpkg

-P

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/371625.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

对多态的理解例子

public class A {public String show(D obj) {return ("A and D");}public String show(A obj) {return ("A and A");} }class B extends A{public String show(B obj){ //重载return ("B and B");}public String show(A obj){ //重写show(A obj…

【Java每日一题】20170120

20170119问题解析请点击今日问题下方的“【Java每日一题】20170120”查看(问题解析在公众号首发,公众号ID:weknow619) package Jan2017; import java.util.Arrays; import java.util.List; public class Ques0120 { publ…

使用NoSQL实现实体服务–第2部分:合同优先

现在该开始使用NoSQL项目对SOA实体服务进行编码了,并且正如我所承诺的,我将从Web服务的合同开始。 看一下本系列的第1部分 。 这种从Web服务合同定义开始的技术是面向服务的体系结构实现的“合同优先”方法的核心,并具有许多技术优势&#xf…

php hugepage,【原创】解决Redis启动报错:Transparent Huge Pages (THP) support enabled in your kernel...

问题背景Redis启动报错:WARNING you have Transparent Huge Pages (THP) support enabled in your kernel.This will create latency and memory usage issues with Redis.To fix this issue run the command echo never > /sys/kernel/mm/transparent_hugepage/…

hibernate cascade的真正含义

hibernate cascade 是 OneToOne OneToMany ManyToOne ManyToMany等注解的属性&#xff0c;表示级联操作。 /*** (Optional) The operations that must be cascaded to* the target of the association.** <p> By default no operations are cascaded.*/CascadeType[] cas…

射线碰撞检测

在我们的游戏开发过程中&#xff0c;有一个很重要的工作就是进行碰撞检测。例如在射击游戏中子弹是否击中敌人&#xff0c;在RPG游戏中是否捡到装备等等。在进行碰撞检测时&#xff0c;我们最常用的工具就是射线&#xff0c;Unity 3D的物理引擎也为我们提供了射线类以及相关的函…

高级ZK:异步UI更新和后台处理–第1部分

异步UI更新非常有用&#xff0c;因为它们通常可以提高响应性&#xff0c;可用性和用户界面的总体感觉。 我将在这里重点介绍ZK框架&#xff0c;但是通常&#xff0c;相同的原理也适用于桌面UI&#xff08;Swing&#xff0c;SWT&#xff09;。 长时间运行的处理 有时&#xff0…

php注册登录遍写入 遍验证,自动注册登录验证机制的php代码

在phpwind站点后台添加“广告管家”(CNZZ的一款广告投放的应用)的应用&#xff0c;整个“广告管家”通过iframe载入&#xff0c;载入的具体内容根据不同站点显示针对该站点的具体内容。出于意用性方面的考虑&#xff0c;需要以下二点&#xff1a;1、首次进入“广告管家”页面自…

转载:tensorflow保存训练后的模型

训练完一个模型后&#xff0c;为了以后重复使用&#xff0c;通常我们需要对模型的结果进行保存。如果用Tensorflow去实现神经网络&#xff0c;所要保存的就是神经网络中的各项权重值。建议可以使用Saver类保存和加载模型的结果。 1、使用tf.train.Saver.save()方法保存模型 tf.…

php url传递变量,php – 在laravel中通过url传递变量

我是laravel的新手,我正在努力让我的网址格式正确.格式为http://mysite/blog?category1 instead of http://mysite/blog/category1这些是我正在使用的文件,有没有办法将路由放入BlogControllerRoute.phpRoute::get(blog/{category}, function($category null){// get all the…

Apache Wicket:记住我的功能

在Web应用程序中&#xff0c;具有“记住我”功能非常普遍&#xff0c;该功能使用户每次访问我们的网站时都能自动登录。 可以使用Spring Security来实现这种功能&#xff0c;但我认为将基于请求的身份验证框架与基于组件的Web框架结合使用并不是最好的主意。 这两个世界不能很好…

Ubuntu 安装中文

系统环境&#xff1a; 1. 官网 http://pinyin.sogou.com/linux/ 下载安装包。 2. 先运行 apt-get update 。 3. 再运行 apt-get -f install 。 4. 再运行 可能有的UBuntu系统自带了。 5. 如果下载的搜狐输入法安装包的格式为 .deb 的&#xff0c; 运行 &#xff1a; dpk…

Eigen教程(10)

整理下Eigen库的教程&#xff0c;参考&#xff1a;http://eigen.tuxfamily.org/dox/index.html 混淆 在Eigen中&#xff0c;当变量同时出现在左值和右值&#xff0c;赋值操作可能会带来混淆问题。这一篇将解释什么是混淆&#xff0c;什么时候是有害的&#xff0c;怎么使用做。 …

matlab把符号数,Matlab 符号与数值之间的转换

符号运算得到的是精确的解析解&#xff0c;但是有时需要进行数值转换&#xff0c;主要通过以下几个函数实现。1.digits 函数调用方法&#xff1a;digits(D)函数设置有效数字个数为D的近似解精度。2.vpa 函数vpaVariable-precision arithmeticSyntaxR vpa(A)R vpa(A,d)Descrip…

JSF组件库–质量不只是零缺陷

自从我上次研究三个主要JSF组件库的质量以来&#xff0c;已经有一段时间了。 2009年12月&#xff0c;我开始比较RichFaces&#xff0c;Primefaces和ICEfaces的整体软件质量 。 从那时起&#xff0c;事情发生了变化&#xff0c;从现在开始&#xff0c;我想重新评估和更新它。 我…

[API档案]GetDlgItem

函数功能 用于获取指定对话框函数控件的句柄。 API函数原型 1 HWND WINAPI GetDlgItem( 2 _In_opt_ HWND hDlg, //指向包含该对话框的句柄 3 _In_ int nIDDlgItem //第二个参数是控件的名称 4 ); 范例 可参见ComboBox_AddString宏的范例【点击这里】转载于:ht…

嵌入式实时系统的任务设计

嵌入式实时系统的任务设计主要为任务函数的设计、任务优先级的安排、任务的数据结构设计&#xff0c;任务之间的同步与通信设计。 一&#xff0e;任务函数的设计 任务函数按任务结构可分为单次执行任务、周期执行任务和事件触发任务&#xff0c;各任务的主要差异点如下&#xf…

mssql php 5.4,PHP5.4如何连接MSSql Server2005

windows系统下&#xff0c;PHP5.3以上的版本已经不支持mssql扩展&#xff0c;所以如果你需要和sql server通信需要到http://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx自行下载微软提供的The SQL Server Driver for PHP。下载后解压缩&#xff0c;将所有的.dll文件拷贝…

将原生SQL功能休眠到您的Spring Data Repository中

JPA为您提供NamedNativeQuery以便使用本机SQL。 但是&#xff0c;用法不是很方便&#xff0c;尤其是当您需要在本机SQL中映射多个实体时。 您必须定义一组容易出错的SqlResultSetMapping映射。 对于以前使用过Hibernate本机SQL功能的用户&#xff0c;您会发现它比JPA的NamedNat…

创建yii的第一个应用

原文链接转载于:https://www.cnblogs.com/Baronboy/p/6354522.html