本篇文章给大家谈谈MySql主键返回使用,以及mysql中主键的知识点,同时本文还将给你拓展Can''tconnecttolocalMySQLserverthroughsocket''/opt/lam
本篇文章给大家谈谈MySql 主键返回使用,以及mysql中主键的知识点,同时本文还将给你拓展Can''t connect to local MySQL server through socket ''/opt/lampp/var/mysql/mysql.sock'' (2)、Can''t connect to local MySQL server through socket ''/var/lib/mysql/mysql.sock''、CentOS yum安装mysql后 Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’、centos7 设置 mysql 自启动的配置文件中 [Service] User=mysql Group=mysql,user 和 group 这边的 mysql 是指的什么?centos 的登录用户名?等相关知识,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:- MySql 主键返回使用(mysql中主键)
- Can''t connect to local MySQL server through socket ''/opt/lampp/var/mysql/mysql.sock'' (2)
- Can''t connect to local MySQL server through socket ''/var/lib/mysql/mysql.sock''
- CentOS yum安装mysql后 Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’
- centos7 设置 mysql 自启动的配置文件中 [Service] User=mysql Group=mysql,user 和 group 这边的 mysql 是指的什么?centos 的登录用户名?
MySql 主键返回使用(mysql中主键)
方法:1.sql 中加入:
<insert id="insertSelective" parameterType="domain.XwRole" useGeneratedKeys="true" keyProperty="id" keyColumn="id" >
insert into t_xw_role
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="name != null" >
name,
</if>
<if test="code != null" >
code,
</if>
<if test="level != null" >
level,
</if>
<if test="parent != null" >
parent,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="name != null" >
#{name,jdbcType=VARCHAR},
</if>
<if test="code != null" >
#{code,jdbcType=VARCHAR},
</if>
<if test="level != null" >
#{level,jdbcType=INTEGER},
</if>
<if test="parent != null" >
#{parent,jdbcType=VARCHAR},
</if>
</trim>
</insert>
2. 在 service 层接收返回的主键
public int add(XwRoleVO xwRoleVo) {
xwRoleVo.setCode(getCode(xwRoleVo));
xwRoleM.insertSelective(xwRoleVo);
return xwRoleVo.getId();
}
方法 2 通过注解方式实现
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
@Insert("INSERT INTO t_all_order (order_no, resident_id, total_amount, deduct_amount, "
+ "payable_amount, address_book_id, pay_status, deliver_status, "
+ "able_status,create_time,total_count,hang_msg,cancel_msg) "
+ "VALUES (#{orderNo}, #{residentId}, #{totalAmount}, #{deductAmount}, #{payableAmount}, "
+ "#{addressBookId}, #{payStatus}, #{deliverStatus}, #{ableStatus},"
+ "#{createTime},#{totalCount},#{hangMsg},#{cancelMsg});")
public int insert(AllOrder allOrder);
在 service 层接收返回的主键
service 层也是绑定到插入的实体类上,同第一种方法里面的获取一样
Can''t connect to local MySQL server through socket ''/opt/lampp/var/mysql/mysql.sock'' (2)
ERROR 2002 (HY000): Can''t connect to local MySQL server through socket ''/opt/lampp/var/mysql/mysql.sock'' (2)
原因:系统盘满了
[root@localhost opt]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
18G 17G 0 100% /
tmpfs 504M 0 504M 0% /dev/shm
/dev/sda1 477M 80M 372M 18% /boot
[root@localhost opt]#
解决:
删除大文件后,重启系统解决
[root@localhost mysql]# /opt/lampp/lampp status
Version: XAMPP for Linux 1.8.3-3
Apache is not running.
MySQL is not running.
ProFTPD is running.
df: 未处理文件系统
[root@localhost opt]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
18G 17G 0 100% /
tmpfs 504M 0 504M 0% /dev/shm
/dev/sda1 477M 80M 372M 18% /boot
[root@localhost opt]#
[root@localhost ~]# /opt/lampp/lampp status
Version: XAMPP for Linux 1.8.3-3
Apache is not running.
MySQL is running.
ProFTPD is running.
转
xampp 无法启动mysql 找不到mysql.sock
(2016-02-24 23:21:24)
分类: 技术 |
如果xampp中的mysql启动不了,出现ERROR 2002 (HY000): Can''t connect to local MySQL server through socket ''/opt/lampp/var/mysql/mysql.sock'' (2)报错,
停止xampp的时候报:
-bash-4.1# /opt/lampp/lampp stop
Stopping XAMPP for Linux 1.8.2-6...
XAMPP: Stopping Apache...ok.
XAMPP: Stopping MySQL...ok.
XAMPP: Stopping ProFTPD...kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
fail.
解决办法:
如果网上一些方法不好用的话,可以试试以下方法:
1. 确定系统盘是否满了
#df -h
2. 删除/opt/lampp目录中的pid文件(删掉后xampp重启时会重建,如果不放心,可以先备份lampp目录)
删除mysql相关缓存:
#rm -rf /opt/lampp/var/mysql/VM_*
删除proftp相关缓存:
#rm -rf /opt/lampp/var/proftpd.pid
如果找不到pid文件,可以搜一下:
#find /opt/lampp -name ''*.pid''
Can''t connect to local MySQL server through socket ''/var/lib/mysql/mysql.sock''
MySQL已经被我移到数据盘了,本地连接数据库会报错:Can''t connect to local MySQL server through socket ''/var/lib/mysql/mysql.sock''
但是远程是可以连接的,my.cnf设置mysql的根目录也改成了数据盘的地址,还要在加上client的参数,设置如下:
[client]
socket = /home/data/mysql/mysql.sock
之后重启下mysql就可以了
CentOS yum安装mysql后 Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’
亲,是不是忘记了开MysqL服务,service MysqLd startcentos7 设置 mysql 自启动的配置文件中 [Service] User=mysql Group=mysql,user 和 group 这边的 mysql 是指的什么?centos 的登录用户名?
centos7 设置 mysql 自启动的配置文件中
[Unit] Description=MySQL Server Documentation=man:mysqld(8) Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html After=network.target After=syslog.target [Install] WantedBy=multi-user.target [Service] User=mysql Group=mysql ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf LimitNOFILE = 5000 #Restart=on-failure #RestartPreventExitStatus=1 #PrivateTmp=false
这里的
[Service]
User=mysql
Group=mysql,
user 和 group 这边的 mysql 是指的什么?centos 的登录用户名?还是其他呢?
今天的关于MySql 主键返回使用和mysql中主键的分享已经结束,谢谢您的关注,如果想了解更多关于Can''t connect to local MySQL server through socket ''/opt/lampp/var/mysql/mysql.sock'' (2)、Can''t connect to local MySQL server through socket ''/var/lib/mysql/mysql.sock''、CentOS yum安装mysql后 Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’、centos7 设置 mysql 自启动的配置文件中 [Service] User=mysql Group=mysql,user 和 group 这边的 mysql 是指的什么?centos 的登录用户名?的相关知识,请在本站进行查询。
本文标签: